diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93f2c0fea..9b6843d51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' @@ -17,13 +19,13 @@ jobs: timeout-minutes: 15 name: lint runs-on: ${{ github.repository == 'stainless-sdks/orb-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -32,7 +34,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3 - name: Run lints run: ./scripts/lint @@ -44,13 +46,13 @@ jobs: contents: read id-token: write runs-on: ${{ github.repository == 'stainless-sdks/orb-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -59,20 +61,24 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/actions/setup-gradle@v4 + uses: gradle/actions/setup-gradle@ed408507eac070d1f99cc633dbcf757c94c7933a # v4.4.3 - name: Build SDK run: ./scripts/build - name: Get GitHub OIDC Token - if: github.repository == 'stainless-sdks/orb-java' + if: |- + github.repository == 'stainless-sdks/orb-java' && + !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v6 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: core.setOutput('github_token', await core.getIDToken()); - name: Build and upload Maven artifacts - if: github.repository == 'stainless-sdks/orb-java' + if: |- + github.repository == 'stainless-sdks/orb-java' && + !startsWith(github.ref, 'refs/heads/stl/') env: URL: https://pkg.stainless.com/s AUTH: ${{ steps.github-oidc.outputs.github_token }} @@ -85,10 +91,10 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/orb-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -97,7 +103,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0 - name: Run tests run: ./scripts/test diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index e92f9580b..074e72029 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Java - uses: actions/setup-java@v5 + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 with: distribution: temurin java-version: | @@ -26,7 +26,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/gradle-build-action@a8f75513eafdebd8141bd1cd4e30fcd194af8dfa # v2.12.0 - name: Publish to Sonatype run: |- diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index ddfc1fdeb..c4079ee94 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'orbcorp/orb-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check release environment run: | diff --git a/.gitignore b/.gitignore index b1346e6d1..90b85e944 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log .gradle .idea .kotlin diff --git a/.release-please-manifest.json b/.release-please-manifest.json index eb4e0dba7..caf148712 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.10.0" + ".": "1.11.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 666bff36b..f3bbb69bb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 126 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c131de17773b450eb1ec03ca001f94d3777e35347234869a7efee083003e1513.yml -openapi_spec_hash: 5d2d4a3a9ada1c381efb318b6897994d -config_hash: bcf82bddb691f6be773ac6cae8c03b9a +configured_endpoints: 139 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb/orb-45297c0f1067cd444a30371110c69f876accf55f303a3dce9a4f74863b59f18f.yml +openapi_spec_hash: cd2f638b98c6e89342397fef860166b7 +config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/CHANGELOG.md b/CHANGELOG.md index 2985ce5a0..b22ae8292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,107 @@ # Changelog +## 1.11.0 (2026-05-22) + +Full Changelog: [v1.10.0...v1.11.0](https://github.com/orbcorp/orb-java/compare/v1.10.0...v1.11.0) + +### Features + +* **api:** api update ([a9e8d7c](https://github.com/orbcorp/orb-java/commit/a9e8d7ce96ffc47877d07adf2e4e48da25872633)) +* **api:** api update ([72265aa](https://github.com/orbcorp/orb-java/commit/72265aab772192c5f713b53fa3f3314e66ba4ee2)) +* **api:** api update ([a42565e](https://github.com/orbcorp/orb-java/commit/a42565ef43485d9f55f62e5fde0e3ebcc162f1b5)) +* **api:** api update ([df70a48](https://github.com/orbcorp/orb-java/commit/df70a48bf466522c5540cef316fd63d0b4591e22)) +* **api:** api update ([7d720b4](https://github.com/orbcorp/orb-java/commit/7d720b40d5f2c01f9b884ef53264f9b60efd0c5b)) +* **api:** api update ([ed6d44c](https://github.com/orbcorp/orb-java/commit/ed6d44c4aa8444bd084257ebd86fb78153bcb2c7)) +* **api:** api update ([1b50fd9](https://github.com/orbcorp/orb-java/commit/1b50fd98c61acd7d7ac75617c817e7f32c62ea23)) +* **api:** api update ([7f58f4b](https://github.com/orbcorp/orb-java/commit/7f58f4b19d30b44e8e2ee69e4e93264960b1d433)) +* **api:** api update ([4435313](https://github.com/orbcorp/orb-java/commit/4435313a9f7fe6e44b4b43d72b540e33ba102c42)) +* **api:** api update ([79cd441](https://github.com/orbcorp/orb-java/commit/79cd4418a453844f56ee7ba4d2e369357fb4db85)) +* **api:** api update ([d5b17d8](https://github.com/orbcorp/orb-java/commit/d5b17d8165c5ce42c1ad5cc6ff9970b90667da01)) +* **api:** api update ([d875ca5](https://github.com/orbcorp/orb-java/commit/d875ca51fd171ccb6f68e671cd80b1ba08b4e56d)) +* **api:** api update ([5bdd885](https://github.com/orbcorp/orb-java/commit/5bdd8852877fe90b5f0b8cd6a4120ab0316a9719)) +* **api:** api update ([e8b8d9a](https://github.com/orbcorp/orb-java/commit/e8b8d9afb5b6340f8a2d16d549e34823fb245dbd)) +* **api:** api update ([1581833](https://github.com/orbcorp/orb-java/commit/15818339bc1d1b2098f3fe0d9c06d8fa4afa0055)) +* **api:** api update ([1152bfb](https://github.com/orbcorp/orb-java/commit/1152bfb0f075438d170bdee2e4c3b02327501057)) +* **api:** api update ([308f7b2](https://github.com/orbcorp/orb-java/commit/308f7b2ed70c479fd7b43e61ffc83e534e137f98)) +* **api:** api update ([36d0db0](https://github.com/orbcorp/orb-java/commit/36d0db01c83dfacb297970d8fc48afad1c81d376)) +* **api:** api update ([bac4aa0](https://github.com/orbcorp/orb-java/commit/bac4aa009a547a636faef396a183d4da5c573933)) +* **api:** api update ([037dbcd](https://github.com/orbcorp/orb-java/commit/037dbcde5fbff819b3a65b43bdc92332a88d96e5)) +* **api:** api update ([014ce03](https://github.com/orbcorp/orb-java/commit/014ce038155006c8874869d82da451b427b5a177)) +* **api:** api update ([4ed5e39](https://github.com/orbcorp/orb-java/commit/4ed5e399e2aeb4ba507314f37ebe510a7f4dcecf)) +* **api:** api update ([522cf9b](https://github.com/orbcorp/orb-java/commit/522cf9bee689650a217f54f12d93f1c548994fa0)) +* **api:** api update ([7661c8c](https://github.com/orbcorp/orb-java/commit/7661c8c5892a01032cf4b24a74b309a2eac77f0c)) +* **api:** api update ([ededc4d](https://github.com/orbcorp/orb-java/commit/ededc4dcf7a0dcbe132f60e4e06b7c0b3c538caa)) +* **api:** api update ([3b82472](https://github.com/orbcorp/orb-java/commit/3b8247255097a5250b47059ca568429a26e0f285)) +* **api:** api update ([c310e36](https://github.com/orbcorp/orb-java/commit/c310e36ffe22fafdd5ba9a00728e7816a8d0e1e6)) +* **api:** api update ([a80ec0b](https://github.com/orbcorp/orb-java/commit/a80ec0b34dabf9595dbae9dfc4b4ed6c914cf5d2)) +* **api:** api update ([69429b9](https://github.com/orbcorp/orb-java/commit/69429b99a2aa15ce52ebd45f7a2a531395f3dc94)) +* **api:** api update ([49d56e2](https://github.com/orbcorp/orb-java/commit/49d56e2d1ef966ebf6ad4508c81b43a19e7cf9c5)) +* **api:** api update ([1e5f897](https://github.com/orbcorp/orb-java/commit/1e5f8972d4dd8c4c955e8980b0c83901a2594bd6)) +* **api:** api update ([eaca79d](https://github.com/orbcorp/orb-java/commit/eaca79da23a8cad0430abcb0319c8a37a5bbfc2a)) +* **api:** manual updates ([5ba9c33](https://github.com/orbcorp/orb-java/commit/5ba9c33bba4f76344046e7cd93946fe96befaf34)) +* **client:** add connection pooling option ([21b4047](https://github.com/orbcorp/orb-java/commit/21b4047e592f1d92782f6aacba9ba0f4d8d893d2)) +* **client:** add more convenience service method overloads ([f56884d](https://github.com/orbcorp/orb-java/commit/f56884dcd6437584dabd311bf0583c6145515e60)) +* **client:** improve logging ([1ca2d2f](https://github.com/orbcorp/orb-java/commit/1ca2d2f249f2554e0737c5c251d6c01b74f36770)) +* **client:** more robust error parsing ([c56994a](https://github.com/orbcorp/orb-java/commit/c56994a7ff8e3d80d514796134161d031ab85c44)) +* **client:** send `X-Stainless-Kotlin-Version` header ([10357a9](https://github.com/orbcorp/orb-java/commit/10357a946d98ffd0cb26409f81af477b4c4638b2)) +* **client:** support proxy authentication ([00a20b6](https://github.com/orbcorp/orb-java/commit/00a20b682a4ba959024b745c40a5713a2dc8e7ab)) +* support setting headers via env ([9b9d608](https://github.com/orbcorp/orb-java/commit/9b9d6087bc5ef54cdf57ff73bda39b2460a908a5)) + + +### Bug Fixes + +* **client:** allow updating header/query affecting fields in `toBuilder()` ([fc7192d](https://github.com/orbcorp/orb-java/commit/fc7192dcba2ed208109219a7df87608648ecbf8e)) +* **client:** incorrect `Retry-After` parsing ([154bdc7](https://github.com/orbcorp/orb-java/commit/154bdc7e119b92a57a9798edf942564f288141a8)) +* **client:** preserve time zone in lenient date-time parsing ([928bfae](https://github.com/orbcorp/orb-java/commit/928bfae14d9e8353f052404bf80873f1bd60d167)) +* fix request delays for retrying to be more respectful of high requested delays ([185d18d](https://github.com/orbcorp/orb-java/commit/185d18dd791129bdbcf9c7c0fe12cdeb34474045)) + + +### Performance Improvements + +* **client:** create one json mapper ([bb2637a](https://github.com/orbcorp/orb-java/commit/bb2637a17a9ef89db3855320700d963fa5c04623)) + + +### Chores + +* **ci:** skip lint on metadata-only changes ([0d80e8a](https://github.com/orbcorp/orb-java/commit/0d80e8ab48e47fa1a00fefb89ef5203849d1b22e)) +* **ci:** skip uploading artifacts on stainless-internal branches ([2b236e9](https://github.com/orbcorp/orb-java/commit/2b236e90a64e621b2f772208c4048ccb1f26c066)) +* **ci:** upgrade `actions/github-script` ([7850067](https://github.com/orbcorp/orb-java/commit/7850067ac12719de79ff00ada02962f035782791)) +* **docs:** add missing descriptions ([d101825](https://github.com/orbcorp/orb-java/commit/d101825fc5db427bb9d36c6b82154919eea85103)) +* drop apache dependency ([edcdb51](https://github.com/orbcorp/orb-java/commit/edcdb514ff66cba287aab7ec5dec282078abb45f)) +* **internal:** allow passing args to `./scripts/test` ([ffbc747](https://github.com/orbcorp/orb-java/commit/ffbc7473823b4ea0ccd27b9cfb85f8a5c165bb47)) +* **internal:** bump palantir-java-format ([82f17f8](https://github.com/orbcorp/orb-java/commit/82f17f8f9081527292cc9ca2bc150d10b2b9dfc1)) +* **internal:** codegen related update ([489bdd6](https://github.com/orbcorp/orb-java/commit/489bdd632da69ee3bafce9d5364861821f235c2b)) +* **internal:** codegen related update ([b8b2251](https://github.com/orbcorp/orb-java/commit/b8b2251ef940a4d3a5276a9287bfc628fcc7fa2b)) +* **internal:** codegen related update ([46abca4](https://github.com/orbcorp/orb-java/commit/46abca478b99884a07ac874f56f5ab7f615d9162)) +* **internal:** correct cache invalidation for `SKIP_MOCK_TESTS` ([4a49c05](https://github.com/orbcorp/orb-java/commit/4a49c05fd112adb44adebff7481d4076ede46058)) +* **internal:** expand imports ([c1195af](https://github.com/orbcorp/orb-java/commit/c1195afe5fc1798dbfd9c8c183501d1e4f33db75)) +* **internal:** make `OkHttp` constructor internal ([05a1acc](https://github.com/orbcorp/orb-java/commit/05a1acc5dd4128fe698db34626ebaaed97ad17f6)) +* **internal:** tweak CI branches ([282b2c1](https://github.com/orbcorp/orb-java/commit/282b2c15ade0d105ae975f9df2476cc647d51f04)) +* **internal:** update `TestServerExtension` comment ([3447469](https://github.com/orbcorp/orb-java/commit/34474693bac76cf4855636d09bac7001108f2ccc)) +* **internal:** update gitignore ([6b9c515](https://github.com/orbcorp/orb-java/commit/6b9c515adf31e37d75ff7507aa5e5b0f6083ce47)) +* **internal:** update maven repo doc to include authentication ([9aa3e27](https://github.com/orbcorp/orb-java/commit/9aa3e2745cf3794784ee229af579142c6d560182)) +* **internal:** update multipart form array serialization ([bd754d3](https://github.com/orbcorp/orb-java/commit/bd754d3554fc55b3a5f52c79111a714ed5d5c236)) +* **internal:** update retry delay tests ([8792a79](https://github.com/orbcorp/orb-java/commit/8792a79536e435e2e4f51c75aaa75129f0db3e3c)) +* **internal:** upgrade AssertJ ([719f036](https://github.com/orbcorp/orb-java/commit/719f036e81d72bf5c80a3e53de1e6fcdee49f15e)) +* make `Properties` more resilient to `null` ([39c553f](https://github.com/orbcorp/orb-java/commit/39c553f7b878162f7affd567e9c0450d1411e653)) +* redact api-key headers in debug logs ([1064c76](https://github.com/orbcorp/orb-java/commit/1064c76a2ef0ab90ed01fae2e89225709ab1873f)) +* **test:** do not count install time for mock server timeout ([efdd6eb](https://github.com/orbcorp/orb-java/commit/efdd6ebf4a150e21f6edc283f5cd8f91ed049b12)) +* **tests:** bump steady to v0.19.4 ([477914f](https://github.com/orbcorp/orb-java/commit/477914f0d8d4ee5c36aa22083629d6e7b3041ae4)) +* **tests:** bump steady to v0.19.5 ([f8a5c1e](https://github.com/orbcorp/orb-java/commit/f8a5c1eabcfb0a78273e78b8e3ca017a0368a098)) +* **tests:** bump steady to v0.19.6 ([26951e7](https://github.com/orbcorp/orb-java/commit/26951e743f106261e4c2f85cf8851e89fd628771)) +* **tests:** bump steady to v0.19.7 ([a8de590](https://github.com/orbcorp/orb-java/commit/a8de590eb5afb9a0ab68e9b50e1ba6cd2ef0e68f)) +* **tests:** bump steady to v0.20.1 ([c9dba44](https://github.com/orbcorp/orb-java/commit/c9dba44e6ff1302d5668d3490ba38799fb86a848)) +* **tests:** bump steady to v0.20.2 ([d480c4b](https://github.com/orbcorp/orb-java/commit/d480c4b2d7fa3ba231ee40b4b79fb3b6d5b6c820)) +* **tests:** bump steady to v0.22.1 ([7a01a25](https://github.com/orbcorp/orb-java/commit/7a01a2582e692add20034607a09ee313fc470f6c)) +* **tests:** update mock server to steady ([3b92540](https://github.com/orbcorp/orb-java/commit/3b92540a62694a2865ef60e244f04b2f6abe4ba2)) + + +### Documentation + +* add comment for arbitrary value fields ([e2f42d1](https://github.com/orbcorp/orb-java/commit/e2f42d1f5d5b951c50798e943a64e14ff134b4f2)) +* clarify forwards compat behavior ([16f10e5](https://github.com/orbcorp/orb-java/commit/16f10e56f568f802c64570477ed9edf082b5e5d0)) +* improve examples ([8e6ac31](https://github.com/orbcorp/orb-java/commit/8e6ac31400bc21c291599235a1c8048a5a9c61b5)) + ## 1.10.0 (2026-01-17) Full Changelog: [v1.9.0...v1.10.0](https://github.com/orbcorp/orb-java/compare/v1.9.0...v1.10.0) diff --git a/README.md b/README.md index be99484ce..222c8dd1c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.10.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.11.0) @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho ### Gradle ```kotlin -implementation("com.withorb.api:orb-java:1.10.0") +implementation("com.withorb.api:orb-java:1.11.0") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:1.10.0") com.withorb.api orb-java - 1.10.0 + 1.11.0 ``` @@ -339,8 +339,6 @@ while (true) { ## Logging -The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). - Enable logging by setting the `ORB_LOG` environment variable to `info`: ```sh @@ -353,6 +351,19 @@ Or to `debug` for more verbose logging: export ORB_LOG=debug ``` +Or configure the client manually using the `logLevel` method: + +```java +import com.withorb.api.client.OrbClient; +import com.withorb.api.client.okhttp.OrbOkHttpClient; +import com.withorb.api.core.LogLevel; + +OrbClient client = OrbOkHttpClient.builder() + .fromEnv() + .logLevel(LogLevel.INFO) + .build(); +``` + ## Webhook Verification We provide helper methods for verifying that a webhook request came from Orb, and not a malicious third party. @@ -457,6 +468,40 @@ OrbClient client = OrbOkHttpClient.builder() .build(); ``` +If the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`: + +```java +import com.withorb.api.client.OrbClient; +import com.withorb.api.client.okhttp.OrbOkHttpClient; +import com.withorb.api.core.http.ProxyAuthenticator; + +OrbClient client = OrbOkHttpClient.builder() + .fromEnv() + .proxy(...) + // Or a custom implementation of `ProxyAuthenticator`. + .proxyAuthenticator(ProxyAuthenticator.basic("username", "password")) + .build(); +``` + +### Connection pooling + +To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: + +```java +import com.withorb.api.client.OrbClient; +import com.withorb.api.client.okhttp.OrbOkHttpClient; +import java.time.Duration; + +OrbClient client = OrbOkHttpClient.builder() + .fromEnv() + // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa. + .maxIdleConnections(10) + .keepAliveDuration(Duration.ofMinutes(2)) + .build(); +``` + +If both options are unset, OkHttp's default connection pool settings are used. + ### HTTPS > [!NOTE] @@ -676,7 +721,9 @@ In rare cases, the API may return a response that doesn't match the expected typ By default, the SDK will not throw an exception in this case. It will throw [`OrbInvalidDataException`](orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbInvalidDataException.kt) only if you directly access the property. -If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: +Validating the response is _not_ forwards compatible with new types from the API for existing fields. + +If you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java import com.withorb.api.models.Customer; diff --git a/build.gradle.kts b/build.gradle.kts index 8e1585b2b..81989492b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ allprojects { group = "com.withorb.api" - version = "1.10.0" // x-release-please-version + version = "1.11.0" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/orb.java.gradle.kts b/buildSrc/src/main/kotlin/orb.java.gradle.kts index 70fc33f41..8f4f902a6 100644 --- a/buildSrc/src/main/kotlin/orb.java.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.java.gradle.kts @@ -45,7 +45,7 @@ tasks.withType().configureEach { val palantir by configurations.creating dependencies { - palantir("com.palantir.javaformat:palantir-java-format:2.73.0") + palantir("com.palantir.javaformat:palantir-java-format:2.89.0") } fun registerPalantir( diff --git a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts index b908b3bed..9f10a4f06 100644 --- a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts @@ -33,11 +33,14 @@ kotlin { tasks.withType().configureEach { systemProperty("junit.jupiter.execution.parallel.enabled", true) systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") + + // `SKIP_MOCK_TESTS` affects which tests run so it must be added as input for proper cache invalidation. + inputs.property("skipMockTests", System.getenv("SKIP_MOCK_TESTS")).optional(true) } val ktfmt by configurations.creating dependencies { - ktfmt("com.facebook:ktfmt:0.56") + ktfmt("com.facebook:ktfmt:0.61") } fun registerKtfmt( diff --git a/examples/.keep b/examples/.keep deleted file mode 100644 index d8c73e937..000000000 --- a/examples/.keep +++ /dev/null @@ -1,4 +0,0 @@ -File generated from our OpenAPI spec by Stainless. - -This directory can be used to store example files demonstrating usage of this SDK. -It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/orb-java-client-okhttp/build.gradle.kts b/orb-java-client-okhttp/build.gradle.kts index 856cade40..08c23763b 100644 --- a/orb-java-client-okhttp/build.gradle.kts +++ b/orb-java-client-okhttp/build.gradle.kts @@ -7,9 +7,8 @@ dependencies { api(project(":orb-java-core")) implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") testImplementation(kotlin("test")) - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") } diff --git a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt index 4d54698c3..1f736002f 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt +++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt @@ -8,20 +8,26 @@ import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpRequestBody import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.ProxyAuthenticator import com.withorb.api.errors.OrbIoException import java.io.IOException import java.io.InputStream +import java.io.OutputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture import java.util.concurrent.ExecutorService +import java.util.concurrent.TimeUnit import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull import okhttp3.Call import okhttp3.Callback +import okhttp3.ConnectionPool import okhttp3.Dispatcher +import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -29,17 +35,18 @@ import okhttp3.Request import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response -import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink +import okio.buffer +import okio.sink class OkHttpClient -private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { +internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) return try { - call.execute().toResponse() + call.execute().toHttpResponse() } catch (e: IOException) { throw OrbIoException("Request failed", e) } finally { @@ -57,7 +64,7 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien call.enqueue( object : Callback { override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) + future.complete(response.toHttpResponse()) } override fun onFailure(call: Call, e: IOException) { @@ -85,18 +92,6 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { val clientBuilder = okHttpClient.newBuilder() - val logLevel = - when (System.getenv("ORB_LOG")?.lowercase()) { - "info" -> HttpLoggingInterceptor.Level.BASIC - "debug" -> HttpLoggingInterceptor.Level.BODY - else -> null - } - if (logLevel != null) { - clientBuilder.addNetworkInterceptor( - HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } - ) - } - requestOptions.timeout?.let { clientBuilder .connectTimeout(it.connect()) @@ -109,89 +104,6 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien return client.newCall(request.toRequest(client)) } - private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { - var body: RequestBody? = body?.toRequestBody() - if (body == null && requiresBody(method)) { - body = "".toRequestBody() - } - - val builder = Request.Builder().url(toUrl()).method(method.name, body) - headers.names().forEach { name -> - headers.values(name).forEach { builder.addHeader(name, it) } - } - - if ( - !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 - ) { - builder.addHeader( - "X-Stainless-Read-Timeout", - Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), - ) - } - if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { - builder.addHeader( - "X-Stainless-Timeout", - Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), - ) - } - - return builder.build() - } - - /** `OkHttpClient` always requires a request body for some methods. */ - private fun requiresBody(method: HttpMethod): Boolean = - when (method) { - HttpMethod.POST, - HttpMethod.PUT, - HttpMethod.PATCH -> true - else -> false - } - - private fun HttpRequest.toUrl(): String { - val builder = baseUrl.toHttpUrl().newBuilder() - pathSegments.forEach(builder::addPathSegment) - queryParams.keys().forEach { key -> - queryParams.values(key).forEach { builder.addQueryParameter(key, it) } - } - - return builder.toString() - } - - private fun HttpRequestBody.toRequestBody(): RequestBody { - val mediaType = contentType()?.toMediaType() - val length = contentLength() - - return object : RequestBody() { - override fun contentType(): MediaType? = mediaType - - override fun contentLength(): Long = length - - override fun isOneShot(): Boolean = !repeatable() - - override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) - } - } - - private fun Response.toResponse(): HttpResponse { - val headers = headers.toHeaders() - - return object : HttpResponse { - override fun statusCode(): Int = code - - override fun headers(): Headers = headers - - override fun body(): InputStream = body!!.byteStream() - - override fun close() = body!!.close() - } - } - - private fun okhttp3.Headers.toHeaders(): Headers { - val headersBuilder = Headers.builder() - forEach { (name, value) -> headersBuilder.put(name, value) } - return headersBuilder.build() - } - companion object { @JvmStatic fun builder() = Builder() } @@ -200,6 +112,9 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null @@ -211,6 +126,32 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + + /** + * Sets the maximum number of idle connections kept by the underlying [ConnectionPool]. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Sets the keep-alive duration for idle connections in the underlying [ConnectionPool]. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { this.dispatcherExecutorService = dispatcherExecutorService } @@ -238,8 +179,37 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien .callTimeout(timeout.request()) .proxy(proxy) .apply { + proxyAuthenticator?.let { auth -> + proxyAuthenticator { route, response -> + auth + .authenticate( + route?.proxy ?: Proxy.NO_PROXY, + response.request.toHttpRequest(), + response.toHttpResponse(), + ) + .getOrNull() + ?.toRequest(client = null) + } + } + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val maxIdleConnections = maxIdleConnections + val keepAliveDuration = keepAliveDuration + if (maxIdleConnections != null && keepAliveDuration != null) { + connectionPool( + ConnectionPool( + maxIdleConnections, + keepAliveDuration.toNanos(), + TimeUnit.NANOSECONDS, + ) + ) + } else { + check((maxIdleConnections != null) == (keepAliveDuration != null)) { + "Both or none of `maxIdleConnections` and `keepAliveDuration` must be set, but only one was set" + } + } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { @@ -261,3 +231,126 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien ) } } + +private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient?): Request { + var body: RequestBody? = body?.toRequestBody() + if (body == null && requiresBody(method)) { + body = "".toRequestBody() + } + + val builder = Request.Builder().url(toUrl()).method(method.name, body) + headers.names().forEach { name -> headers.values(name).forEach { builder.addHeader(name, it) } } + + if (client != null) { + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.addHeader( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.addHeader( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } + } + + return builder.build() +} + +/** `OkHttpClient` always requires a request body for some methods. */ +private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + +private fun HttpRequest.toUrl(): String { + val builder = baseUrl.toHttpUrl().newBuilder() + pathSegments.forEach(builder::addPathSegment) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } + + return builder.toString() +} + +private fun HttpRequestBody.toRequestBody(): RequestBody { + val mediaType = contentType()?.toMediaType() + val length = contentLength() + + return object : RequestBody() { + override fun contentType(): MediaType? = mediaType + + override fun contentLength(): Long = length + + override fun isOneShot(): Boolean = !repeatable() + + override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) + } +} + +private fun Request.toHttpRequest(): HttpRequest { + val builder = HttpRequest.builder().method(HttpMethod.valueOf(method)).baseUrl(url.toBaseUrl()) + url.pathSegments.forEach(builder::addPathSegment) + url.queryParameterNames.forEach { name -> + url.queryParameterValues(name).filterNotNull().forEach { builder.putQueryParam(name, it) } + } + headers.forEach { (name, value) -> builder.putHeader(name, value) } + body?.let { builder.body(it.toHttpRequestBody()) } + return builder.build() +} + +private fun HttpUrl.toBaseUrl(): String = buildString { + append(scheme).append("://").append(host) + if (port != HttpUrl.defaultPort(scheme)) { + append(":").append(port) + } +} + +private fun RequestBody.toHttpRequestBody(): HttpRequestBody { + val mediaType = contentType()?.toString() + val length = contentLength() + val isOneShot = isOneShot() + val source = this + return object : HttpRequestBody { + override fun contentType(): String? = mediaType + + override fun contentLength(): Long = length + + override fun repeatable(): Boolean = !isOneShot + + override fun writeTo(outputStream: OutputStream) { + val sink = outputStream.sink().buffer() + source.writeTo(sink) + sink.flush() + } + + override fun close() {} + } +} + +private fun Response.toHttpResponse(): HttpResponse { + val headers = headers.toHeaders() + + return object : HttpResponse { + override fun statusCode(): Int = code + + override fun headers(): Headers = headers + + override fun body(): InputStream = body!!.byteStream() + + override fun close() = body!!.close() + } +} + +private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() +} 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 efc83cf9b..90fc352e1 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt +++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt @@ -6,11 +6,13 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.withorb.api.client.OrbClient import com.withorb.api.client.OrbClientImpl import com.withorb.api.core.ClientOptions +import com.withorb.api.core.LogLevel import com.withorb.api.core.Sleeper import com.withorb.api.core.Timeout import com.withorb.api.core.http.AsyncStreamResponse import com.withorb.api.core.http.Headers import com.withorb.api.core.http.HttpClient +import com.withorb.api.core.http.ProxyAuthenticator import com.withorb.api.core.http.QueryParams import com.withorb.api.core.jsonMapper import java.net.Proxy @@ -49,6 +51,9 @@ class OrbOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -77,6 +82,60 @@ class OrbOkHttpClient private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication + * Required`. + */ + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + + /** + * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`. + */ + fun proxyAuthenticator(proxyAuthenticator: Optional) = + proxyAuthenticator(proxyAuthenticator.getOrNull()) + + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`. + */ + fun maxIdleConnections(maxIdleConnections: Optional) = + maxIdleConnections(maxIdleConnections.getOrNull()) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + + /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */ + fun keepAliveDuration(keepAliveDuration: Optional) = + keepAliveDuration(keepAliveDuration.getOrNull()) + /** * The socket factory used to secure HTTPS connections. * @@ -188,6 +247,9 @@ class OrbOkHttpClient private constructor() { /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -229,6 +291,15 @@ class OrbOkHttpClient private constructor() { */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + fun logLevel(logLevel: LogLevel) = apply { clientOptions.logLevel(logLevel) } + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } fun webhookSecret(webhookSecret: String?) = apply { @@ -338,6 +409,9 @@ class OrbOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .proxyAuthenticator(proxyAuthenticator) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) 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 0a71facec..c8a415906 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt +++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt @@ -6,11 +6,13 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.withorb.api.client.OrbClientAsync import com.withorb.api.client.OrbClientAsyncImpl import com.withorb.api.core.ClientOptions +import com.withorb.api.core.LogLevel import com.withorb.api.core.Sleeper import com.withorb.api.core.Timeout import com.withorb.api.core.http.AsyncStreamResponse import com.withorb.api.core.http.Headers import com.withorb.api.core.http.HttpClient +import com.withorb.api.core.http.ProxyAuthenticator import com.withorb.api.core.http.QueryParams import com.withorb.api.core.jsonMapper import java.net.Proxy @@ -49,6 +51,9 @@ class OrbOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -77,6 +82,60 @@ class OrbOkHttpClientAsync private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication + * Required`. + */ + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + + /** + * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`. + */ + fun proxyAuthenticator(proxyAuthenticator: Optional) = + proxyAuthenticator(proxyAuthenticator.getOrNull()) + + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`. + */ + fun maxIdleConnections(maxIdleConnections: Optional) = + maxIdleConnections(maxIdleConnections.getOrNull()) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + + /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */ + fun keepAliveDuration(keepAliveDuration: Optional) = + keepAliveDuration(keepAliveDuration.getOrNull()) + /** * The socket factory used to secure HTTPS connections. * @@ -188,6 +247,9 @@ class OrbOkHttpClientAsync private constructor() { /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -229,6 +291,15 @@ class OrbOkHttpClientAsync private constructor() { */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + fun logLevel(logLevel: LogLevel) = apply { clientOptions.logLevel(logLevel) } + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } fun webhookSecret(webhookSecret: String?) = apply { @@ -338,6 +409,9 @@ class OrbOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .proxyAuthenticator(proxyAuthenticator) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) diff --git a/orb-java-core/build.gradle.kts b/orb-java-core/build.gradle.kts index 086a58f55..72660d18e 100644 --- a/orb-java-core/build.gradle.kts +++ b/orb-java-core/build.gradle.kts @@ -27,13 +27,11 @@ dependencies { implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") - implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") - implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") testImplementation(kotlin("test")) testImplementation(project(":orb-java-client-okhttp")) testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt index b3cc3efcc..6a41f268b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt @@ -14,6 +14,8 @@ import com.withorb.api.services.blocking.EventService import com.withorb.api.services.blocking.InvoiceLineItemService import com.withorb.api.services.blocking.InvoiceService import com.withorb.api.services.blocking.ItemService +import com.withorb.api.services.blocking.LicenseService +import com.withorb.api.services.blocking.LicenseTypeService import com.withorb.api.services.blocking.MetricService import com.withorb.api.services.blocking.PlanService import com.withorb.api.services.blocking.PriceService @@ -61,40 +63,137 @@ interface OrbClient { fun topLevel(): TopLevelService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun beta(): BetaService + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun coupons(): CouponService + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ fun creditNotes(): CreditNoteService + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun customers(): CustomerService + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun events(): EventService + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemService + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoices(): InvoiceService + /** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for + * invoices and tax calculation purposes. + */ fun items(): ItemService + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun plans(): PlanService + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceService fun subscriptions(): SubscriptionService fun webhooks(): WebhookService + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertService fun dimensionalPriceGroups(): DimensionalPriceGroupService fun subscriptionChanges(): SubscriptionChangeService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockService + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ + fun licenseTypes(): LicenseTypeService + + fun licenses(): LicenseService + /** * Closes this client, relinquishing any underlying resources. * @@ -120,36 +219,133 @@ interface OrbClient { fun topLevel(): TopLevelService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun beta(): BetaService.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun coupons(): CouponService.WithRawResponse + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ fun creditNotes(): CreditNoteService.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun customers(): CustomerService.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun events(): EventService.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemService.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoices(): InvoiceService.WithRawResponse + /** + * The Item resource represents a sellable product or good. Items are associated with all + * line items, billable metrics, and prices and are used for defining external sync behavior + * for invoices and tax calculation purposes. + */ fun items(): ItemService.WithRawResponse + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun plans(): PlanService.WithRawResponse + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceService.WithRawResponse fun subscriptions(): SubscriptionService.WithRawResponse + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertService.WithRawResponse fun dimensionalPriceGroups(): DimensionalPriceGroupService.WithRawResponse fun subscriptionChanges(): SubscriptionChangeService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockService.WithRawResponse + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + fun licenseTypes(): LicenseTypeService.WithRawResponse + + fun licenses(): LicenseService.WithRawResponse } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt index a8b535120..3857f7297 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt @@ -14,6 +14,8 @@ import com.withorb.api.services.async.EventServiceAsync import com.withorb.api.services.async.InvoiceLineItemServiceAsync import com.withorb.api.services.async.InvoiceServiceAsync import com.withorb.api.services.async.ItemServiceAsync +import com.withorb.api.services.async.LicenseServiceAsync +import com.withorb.api.services.async.LicenseTypeServiceAsync import com.withorb.api.services.async.MetricServiceAsync import com.withorb.api.services.async.PlanServiceAsync import com.withorb.api.services.async.PriceServiceAsync @@ -60,38 +62,135 @@ interface OrbClientAsync { fun topLevel(): TopLevelServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun beta(): BetaServiceAsync + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun coupons(): CouponServiceAsync + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ fun creditNotes(): CreditNoteServiceAsync + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun customers(): CustomerServiceAsync + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun events(): EventServiceAsync + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemServiceAsync + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ fun invoices(): InvoiceServiceAsync + /** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for + * invoices and tax calculation purposes. + */ fun items(): ItemServiceAsync + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun plans(): PlanServiceAsync + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceServiceAsync fun subscriptions(): SubscriptionServiceAsync + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertServiceAsync fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync fun subscriptionChanges(): SubscriptionChangeServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockServiceAsync + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ + fun licenseTypes(): LicenseTypeServiceAsync + + fun licenses(): LicenseServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -117,36 +216,133 @@ interface OrbClientAsync { fun topLevel(): TopLevelServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun beta(): BetaServiceAsync.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun coupons(): CouponServiceAsync.WithRawResponse + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ fun creditNotes(): CreditNoteServiceAsync.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun customers(): CustomerServiceAsync.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun events(): EventServiceAsync.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoiceLineItems(): InvoiceLineItemServiceAsync.WithRawResponse + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ fun invoices(): InvoiceServiceAsync.WithRawResponse + /** + * The Item resource represents a sellable product or good. Items are associated with all + * line items, billable metrics, and prices and are used for defining external sync behavior + * for invoices and tax calculation purposes. + */ fun items(): ItemServiceAsync.WithRawResponse + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ fun metrics(): MetricServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun plans(): PlanServiceAsync.WithRawResponse + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun prices(): PriceServiceAsync.WithRawResponse fun subscriptions(): SubscriptionServiceAsync.WithRawResponse + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ fun alerts(): AlertServiceAsync.WithRawResponse fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.WithRawResponse fun subscriptionChanges(): SubscriptionChangeServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun creditBlocks(): CreditBlockServiceAsync.WithRawResponse + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + fun licenseTypes(): LicenseTypeServiceAsync.WithRawResponse + + fun licenses(): LicenseServiceAsync.WithRawResponse } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt index ba4b5c44a..d20aa3a60 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt @@ -26,6 +26,10 @@ import com.withorb.api.services.async.InvoiceServiceAsync import com.withorb.api.services.async.InvoiceServiceAsyncImpl import com.withorb.api.services.async.ItemServiceAsync import com.withorb.api.services.async.ItemServiceAsyncImpl +import com.withorb.api.services.async.LicenseServiceAsync +import com.withorb.api.services.async.LicenseServiceAsyncImpl +import com.withorb.api.services.async.LicenseTypeServiceAsync +import com.withorb.api.services.async.LicenseTypeServiceAsyncImpl import com.withorb.api.services.async.MetricServiceAsync import com.withorb.api.services.async.MetricServiceAsyncImpl import com.withorb.api.services.async.PlanServiceAsync @@ -119,6 +123,14 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs CreditBlockServiceAsyncImpl(clientOptionsWithUserAgent) } + private val licenseTypes: LicenseTypeServiceAsync by lazy { + LicenseTypeServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val licenses: LicenseServiceAsync by lazy { + LicenseServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): OrbClient = sync override fun withRawResponse(): OrbClientAsync.WithRawResponse = withRawResponse @@ -128,30 +140,115 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun topLevel(): TopLevelServiceAsync = topLevel + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun beta(): BetaServiceAsync = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun coupons(): CouponServiceAsync = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ override fun creditNotes(): CreditNoteServiceAsync = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun customers(): CustomerServiceAsync = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun events(): EventServiceAsync = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemServiceAsync = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoices(): InvoiceServiceAsync = invoices + /** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for + * invoices and tax calculation purposes. + */ override fun items(): ItemServiceAsync = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricServiceAsync = metrics + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun plans(): PlanServiceAsync = plans + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceServiceAsync = prices override fun subscriptions(): SubscriptionServiceAsync = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertServiceAsync = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync = @@ -159,8 +256,20 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun subscriptionChanges(): SubscriptionChangeServiceAsync = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockServiceAsync = creditBlocks + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ + override fun licenseTypes(): LicenseTypeServiceAsync = licenseTypes + + override fun licenses(): LicenseServiceAsync = licenses + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -235,6 +344,14 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs CreditBlockServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val licenseTypes: LicenseTypeServiceAsync.WithRawResponse by lazy { + LicenseTypeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val licenses: LicenseServiceAsync.WithRawResponse by lazy { + LicenseServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): OrbClientAsync.WithRawResponse = @@ -244,31 +361,116 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun beta(): BetaServiceAsync.WithRawResponse = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun coupons(): CouponServiceAsync.WithRawResponse = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ override fun creditNotes(): CreditNoteServiceAsync.WithRawResponse = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun customers(): CustomerServiceAsync.WithRawResponse = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun events(): EventServiceAsync.WithRawResponse = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemServiceAsync.WithRawResponse = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoices(): InvoiceServiceAsync.WithRawResponse = invoices + /** + * The Item resource represents a sellable product or good. Items are associated with all + * line items, billable metrics, and prices and are used for defining external sync behavior + * for invoices and tax calculation purposes. + */ override fun items(): ItemServiceAsync.WithRawResponse = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricServiceAsync.WithRawResponse = metrics + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun plans(): PlanServiceAsync.WithRawResponse = plans + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceServiceAsync.WithRawResponse = prices override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertServiceAsync.WithRawResponse = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.WithRawResponse = @@ -277,6 +479,18 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun subscriptionChanges(): SubscriptionChangeServiceAsync.WithRawResponse = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockServiceAsync.WithRawResponse = creditBlocks + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + override fun licenseTypes(): LicenseTypeServiceAsync.WithRawResponse = licenseTypes + + override fun licenses(): LicenseServiceAsync.WithRawResponse = licenses } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt index 4fa187d47..a39b97ca1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt @@ -26,6 +26,10 @@ import com.withorb.api.services.blocking.InvoiceService import com.withorb.api.services.blocking.InvoiceServiceImpl import com.withorb.api.services.blocking.ItemService import com.withorb.api.services.blocking.ItemServiceImpl +import com.withorb.api.services.blocking.LicenseService +import com.withorb.api.services.blocking.LicenseServiceImpl +import com.withorb.api.services.blocking.LicenseTypeService +import com.withorb.api.services.blocking.LicenseTypeServiceImpl import com.withorb.api.services.blocking.MetricService import com.withorb.api.services.blocking.MetricServiceImpl import com.withorb.api.services.blocking.PlanService @@ -111,6 +115,12 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { CreditBlockServiceImpl(clientOptionsWithUserAgent) } + private val licenseTypes: LicenseTypeService by lazy { + LicenseTypeServiceImpl(clientOptionsWithUserAgent) + } + + private val licenses: LicenseService by lazy { LicenseServiceImpl(clientOptionsWithUserAgent) } + override fun async(): OrbClientAsync = async override fun withRawResponse(): OrbClient.WithRawResponse = withRawResponse @@ -120,40 +130,137 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun topLevel(): TopLevelService = topLevel + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun beta(): BetaService = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun coupons(): CouponService = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied + * to a particular invoice. + */ override fun creditNotes(): CreditNoteService = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun customers(): CustomerService = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun events(): EventService = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemService = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of an + * action, such as a cancellation. + */ override fun invoices(): InvoiceService = invoices + /** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for + * invoices and tax calculation purposes. + */ override fun items(): ItemService = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricService = metrics + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun plans(): PlanService = plans + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceService = prices override fun subscriptions(): SubscriptionService = subscriptions override fun webhooks(): WebhookService = webhooks + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertService = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupService = dimensionalPriceGroups override fun subscriptionChanges(): SubscriptionChangeService = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockService = creditBlocks + /** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ + override fun licenseTypes(): LicenseTypeService = licenseTypes + + override fun licenses(): LicenseService = licenses + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -227,6 +334,14 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { CreditBlockServiceImpl.WithRawResponseImpl(clientOptions) } + private val licenseTypes: LicenseTypeService.WithRawResponse by lazy { + LicenseTypeServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val licenses: LicenseService.WithRawResponse by lazy { + LicenseServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): OrbClient.WithRawResponse = @@ -236,30 +351,115 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun topLevel(): TopLevelService.WithRawResponse = topLevel + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun beta(): BetaService.WithRawResponse = beta + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun coupons(): CouponService.WithRawResponse = coupons + /** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been + * applied to a particular invoice. + */ override fun creditNotes(): CreditNoteService.WithRawResponse = creditNotes + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun customers(): CustomerService.WithRawResponse = customers + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun events(): EventService.WithRawResponse = events + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoiceLineItems(): InvoiceLineItemService.WithRawResponse = invoiceLineItems + /** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the + * request for payment for a single subscription. This includes a set of line items, which + * correspond to prices in the subscription's plan and can represent fixed recurring fees or + * usage-based fees. They are generated at the end of a billing period, or as the result of + * an action, such as a cancellation. + */ override fun invoices(): InvoiceService.WithRawResponse = invoices + /** + * The Item resource represents a sellable product or good. Items are associated with all + * line items, billable metrics, and prices and are used for defining external sync behavior + * for invoices and tax calculation purposes. + */ override fun items(): ItemService.WithRawResponse = items + /** + * The Metric resource represents a calculation of a quantity based on events. Metrics are + * defined by the query that transforms raw usage events into meaningful values for your + * customers. + */ override fun metrics(): MetricService.WithRawResponse = metrics + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun plans(): PlanService.WithRawResponse = plans + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun prices(): PriceService.WithRawResponse = prices override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions + /** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or + * credit balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ override fun alerts(): AlertService.WithRawResponse = alerts override fun dimensionalPriceGroups(): DimensionalPriceGroupService.WithRawResponse = @@ -268,6 +468,18 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun subscriptionChanges(): SubscriptionChangeService.WithRawResponse = subscriptionChanges + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun creditBlocks(): CreditBlockService.WithRawResponse = creditBlocks + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + override fun licenseTypes(): LicenseTypeService.WithRawResponse = licenseTypes + + override fun licenses(): LicenseService.WithRawResponse = licenses } } 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 cd66b87cb..ba7547902 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 @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.withorb.api.core.http.AsyncStreamResponse import com.withorb.api.core.http.Headers import com.withorb.api.core.http.HttpClient +import com.withorb.api.core.http.LoggingHttpClient import com.withorb.api.core.http.PhantomReachableClosingHttpClient import com.withorb.api.core.http.QueryParams import com.withorb.api.core.http.RetryingHttpClient @@ -80,6 +81,9 @@ private constructor( /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for existing + * fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -107,6 +111,14 @@ private constructor( * Defaults to 2. */ @get:JvmName("maxRetries") val maxRetries: Int, + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + @get:JvmName("logLevel") val logLevel: LogLevel, @get:JvmName("apiKey") val apiKey: String, private val webhookSecret: String?, ) { @@ -166,6 +178,7 @@ private constructor( private var responseValidation: Boolean = false private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 + private var logLevel: LogLevel = LogLevel.fromEnv() private var apiKey: String? = null private var webhookSecret: String? = null @@ -183,6 +196,7 @@ private constructor( responseValidation = clientOptions.responseValidation timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries + logLevel = clientOptions.logLevel apiKey = clientOptions.apiKey webhookSecret = clientOptions.webhookSecret } @@ -264,6 +278,9 @@ private constructor( /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -305,6 +322,15 @@ private constructor( */ fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + fun logLevel(logLevel: LogLevel) = apply { this.logLevel = logLevel } + fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } @@ -409,6 +435,7 @@ private constructor( * System properties take precedence over environment variables. */ fun fromEnv() = apply { + logLevel(LogLevel.fromEnv()) (System.getProperty("orb.baseUrl") ?: System.getenv("ORB_BASE_URL"))?.let { baseUrl(it) } @@ -416,6 +443,14 @@ private constructor( (System.getProperty("orb.webhookSecret") ?: System.getenv("ORB_WEBHOOK_SECRET"))?.let { webhookSecret(it) } + System.getenv("ORB_CUSTOM_HEADERS")?.let { customHeadersEnv -> + for (line in customHeadersEnv.split("\n")) { + val colon = line.indexOf(':') + if (colon >= 0) { + putHeader(line.substring(0, colon).trim(), line.substring(colon + 1).trim()) + } + } + } } /** @@ -463,18 +498,26 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) + // We replace after all the default headers to allow end-users to overwrite them. + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) apiKey.let { if (!it.isEmpty()) { - headers.put("Authorization", "Bearer $it") + headers.replace("Authorization", "Bearer $it") } } - headers.replaceAll(this.headers.build()) - queryParams.replaceAll(this.queryParams.build()) return ClientOptions( httpClient, RetryingHttpClient.builder() - .httpClient(httpClient) + .httpClient( + LoggingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .level(logLevel) + .build() + ) .sleeper(sleeper) .clock(clock) .maxRetries(maxRetries) @@ -491,6 +534,7 @@ private constructor( responseValidation, timeout, maxRetries, + logLevel, apiKey, webhookSecret, ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/LogLevel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/LogLevel.kt new file mode 100644 index 000000000..5232bb6e4 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/LogLevel.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core + +/** The level at which to log request and response information. */ +enum class LogLevel { + /** No logging. */ + OFF, + /** Minimal request and response summary logs. No headers or bodies are logged. */ + INFO, + /** [INFO] logs plus details about request failures. */ + ERROR, + /** + * Full request and response logs. Sensitive headers are redacted, but sensitive data in request + * and response bodies may still be visible. + */ + DEBUG; + + /** Returns whether this level is at or higher than the given [level]. */ + fun shouldLog(level: LogLevel): Boolean = ordinal >= level.ordinal + + companion object { + + /** Returns a [LogLevel] based on the `ORB_LOG` environment variable. */ + fun fromEnv() = + when (System.getenv("ORB_LOG")?.lowercase()) { + "info" -> INFO + "error" -> ERROR + "debug" -> DEBUG + else -> OFF + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt index 1373ca6ce..5361d4e66 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ObjectMappers.kt @@ -25,11 +25,13 @@ import java.time.DateTimeException import java.time.LocalDate import java.time.LocalDateTime import java.time.OffsetDateTime -import java.time.ZonedDateTime +import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField -fun jsonMapper(): JsonMapper = +fun jsonMapper(): JsonMapper = JSON_MAPPER + +private val JSON_MAPPER: JsonMapper = JsonMapper.builder() .addModule(kotlinModule()) .addModule(Jdk8Module()) @@ -157,14 +159,15 @@ private class LenientOffsetDateTimeDeserializer : val temporal = formatter.parse(p.text) return when { - !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> - LocalDate.from(temporal).atStartOfDay() - !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> - LocalDateTime.from(temporal) - else -> ZonedDateTime.from(temporal).toLocalDateTime() - } - .atZone(context.timeZone.toZoneId()) - .toOffsetDateTime() + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal) + .atStartOfDay() + .atZone(ZoneId.of("UTC")) + .toOffsetDateTime() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal).atZone(ZoneId.of("UTC")).toOffsetDateTime() + else -> OffsetDateTime.from(temporal) + } } catch (e: DateTimeException) { exceptions.add(e) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt index f0f63ba44..e21bb1e93 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Properties.kt @@ -34,8 +34,9 @@ fun getOsName(): String { } } -fun getOsVersion(): String = System.getProperty("os.version", "unknown") +fun getOsVersion(): String = System.getProperty("os.version", "unknown") ?: "unknown" -fun getPackageVersion(): String = OrbClient::class.java.`package`.implementationVersion ?: "unknown" +fun getPackageVersion(): String = + OrbClient::class.java.`package`?.implementationVersion ?: "unknown" -fun getJavaVersion(): String = System.getProperty("java.version", "unknown") +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") ?: "unknown" diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/RequestOptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/RequestOptions.kt index 1f3b64291..c4be16ab4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/RequestOptions.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/RequestOptions.kt @@ -33,6 +33,15 @@ class RequestOptions private constructor(val responseValidation: Boolean?, val t private var responseValidation: Boolean? = null private var timeout: Timeout? = null + /** + * Whether to call `validate` on the response before returning it. + * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt index c392401d6..2b3f5319a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Utils.kt @@ -6,6 +6,7 @@ import com.withorb.api.core.http.Headers import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.SortedMap +import java.util.SortedSet import java.util.concurrent.CompletableFuture import java.util.concurrent.locks.Lock @@ -17,6 +18,11 @@ internal fun T?.getOrThrow(name: String): T = internal fun List.toImmutable(): List = if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList()) +@JvmSynthetic +internal fun > SortedSet.toImmutable(): SortedSet = + if (isEmpty()) Collections.emptySortedSet() + else Collections.unmodifiableSortedSet(toSortedSet(comparator() ?: Comparator.naturalOrder())) + @JvmSynthetic internal fun Map.toImmutable(): Map = if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt index 3463de9ea..4b7b62d15 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt @@ -8,13 +8,13 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.node.JsonNodeType import com.withorb.api.core.MultipartField +import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException +import java.io.ByteArrayInputStream import java.io.InputStream import java.io.OutputStream +import java.util.UUID import kotlin.jvm.optionals.getOrNull -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder -import org.apache.hc.core5.http.ContentType -import org.apache.hc.core5.http.HttpEntity @JvmSynthetic internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = @@ -37,69 +37,207 @@ internal fun multipartFormData( jsonMapper: JsonMapper, fields: Map>, ): HttpRequestBody = - object : HttpRequestBody { - private val entity: HttpEntity by lazy { - MultipartEntityBuilder.create() - .apply { - fields.forEach { (name, field) -> - val knownValue = field.value.asKnown().getOrNull() - val parts = - if (knownValue is InputStream) { - // Read directly from the `InputStream` instead of reading it all - // into memory due to the `jsonMapper` serialization below. - sequenceOf(name to knownValue) - } else { - val node = jsonMapper.valueToTree(field.value) - serializePart(name, node) + MultipartBody.Builder() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + val partBody = + if (bytes is ByteArrayInputStream) { + val byteArray = bytes.readBytes() + + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + outputStream.write(byteArray) + } + + override fun contentType(): String = field.contentType + + override fun contentLength(): Long = byteArray.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} } + } else { + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + bytes.copyTo(outputStream) + } + + override fun contentType(): String = field.contentType - parts.forEach { (name, bytes) -> - addBinaryBody( - name, - bytes, - ContentType.parseLenient(field.contentType), - field.filename().getOrNull(), - ) + override fun contentLength(): Long = -1L + + override fun repeatable(): Boolean = false + + override fun close() = bytes.close() + } } - } + + addPart( + MultipartBody.Part.create( + name, + field.filename().getOrNull(), + field.contentType, + partBody, + ) + ) } - .build() + } } + .build() + +private fun serializePart(name: String, node: JsonNode): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().byteInputStream()) + JsonNodeType.BOOLEAN -> sequenceOf(name to node.booleanValue().toString().byteInputStream()) + JsonNodeType.NUMBER -> sequenceOf(name to node.numberValue().toString().byteInputStream()) + JsonNodeType.ARRAY -> + node.elements().asSequence().flatMap { element -> serializePart("$name[]", element) } + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> throw OrbInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") + } - private fun serializePart( - name: String, - node: JsonNode, - ): Sequence> = - when (node.nodeType) { - JsonNodeType.MISSING, - JsonNodeType.NULL -> emptySequence() - JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) - JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) - JsonNodeType.BOOLEAN -> - sequenceOf(name to node.booleanValue().toString().inputStream()) - JsonNodeType.NUMBER -> - sequenceOf(name to node.numberValue().toString().inputStream()) - JsonNodeType.ARRAY -> - node.elements().asSequence().flatMap { element -> - serializePart("$name[]", element) - } - JsonNodeType.OBJECT -> - node.fields().asSequence().flatMap { (key, value) -> - serializePart("$name[$key]", value) - } - JsonNodeType.POJO, - null -> throw OrbInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") +private class MultipartBody +private constructor(private val boundary: String, private val parts: List) : HttpRequestBody { + private val boundaryBytes: ByteArray = boundary.toByteArray() + private val contentType = "multipart/form-data; boundary=$boundary" + + // This must remain in sync with `contentLength`. + override fun writeTo(outputStream: OutputStream) { + parts.forEach { part -> + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(CRLF) + + outputStream.write(CONTENT_DISPOSITION) + outputStream.write(part.contentDisposition.toByteArray()) + outputStream.write(CRLF) + + outputStream.write(CONTENT_TYPE) + outputStream.write(part.contentType.toByteArray()) + outputStream.write(CRLF) + + outputStream.write(CRLF) + part.body.writeTo(outputStream) + outputStream.write(CRLF) + } + + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(DASHDASH) + outputStream.write(CRLF) + } + + override fun contentType(): String = contentType + + // This must remain in sync with `writeTo`. + override fun contentLength(): Long { + var byteCount = 0L + + parts.forEach { part -> + val contentLength = part.body.contentLength() + if (contentLength == -1L) { + return -1L } - private fun String.inputStream(): InputStream = toByteArray().inputStream() + byteCount += + DASHDASH.size + + boundaryBytes.size + + CRLF.size + + CONTENT_DISPOSITION.size + + part.contentDisposition.toByteArray().size + + CRLF.size + + CONTENT_TYPE.size + + part.contentType.toByteArray().size + + CRLF.size + + CRLF.size + + contentLength + + CRLF.size + } - override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + byteCount += DASHDASH.size + boundaryBytes.size + DASHDASH.size + CRLF.size + return byteCount + } - override fun contentType(): String = entity.contentType + override fun repeatable(): Boolean = parts.all { it.body.repeatable() } - override fun contentLength(): Long = entity.contentLength + override fun close() { + parts.forEach { it.body.close() } + } - override fun repeatable(): Boolean = entity.isRepeatable + class Builder { + private val boundary = UUID.randomUUID().toString() + private val parts: MutableList = mutableListOf() - override fun close() = entity.close() + fun addPart(part: Part) = apply { parts.add(part) } + + fun build() = MultipartBody(boundary, parts.toImmutable()) + } + + class Part + private constructor( + val contentDisposition: String, + val contentType: String, + val body: HttpRequestBody, + ) { + companion object { + fun create( + name: String, + filename: String?, + contentType: String, + body: HttpRequestBody, + ): Part { + val disposition = buildString { + append("form-data; name=") + appendQuotedString(name) + if (filename != null) { + append("; filename=") + appendQuotedString(filename) + } + } + return Part(disposition, contentType, body) + } + } + } + + companion object { + private val CRLF = byteArrayOf('\r'.code.toByte(), '\n'.code.toByte()) + private val DASHDASH = byteArrayOf('-'.code.toByte(), '-'.code.toByte()) + private val CONTENT_DISPOSITION = "Content-Disposition: ".toByteArray() + private val CONTENT_TYPE = "Content-Type: ".toByteArray() + + private fun StringBuilder.appendQuotedString(key: String) { + append('"') + for (ch in key) { + when (ch) { + '\n' -> append("%0A") + '\r' -> append("%0D") + '"' -> append("%22") + else -> append(ch) + } + } + append('"') + } } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/LoggingHttpClient.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/LoggingHttpClient.kt new file mode 100644 index 000000000..f528b6634 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/LoggingHttpClient.kt @@ -0,0 +1,628 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core.http + +import com.withorb.api.core.LogLevel +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import java.io.ByteArrayOutputStream +import java.io.InputStream +import java.io.OutputStream +import java.nio.ByteBuffer +import java.nio.charset.CharacterCodingException +import java.nio.charset.Charset +import java.nio.charset.CharsetDecoder +import java.nio.charset.CodingErrorAction +import java.nio.charset.StandardCharsets +import java.time.Clock +import java.time.Duration +import java.time.OffsetDateTime +import java.util.SortedSet +import java.util.concurrent.CompletableFuture +import java.util.concurrent.CompletionException +import kotlin.time.toKotlinDuration + +/** A wrapper [HttpClient] around [httpClient] that logs request and response information. */ +class LoggingHttpClient +private constructor( + /** The underlying [HttpClient] for making requests. */ + @get:JvmName("httpClient") val httpClient: HttpClient, + /** + * Sensitive headers to redact from logs. + * + * Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie")`. + */ + @get:JvmName("redactedHeaders") val redactedHeaders: SortedSet, + /** + * The clock to use for measuring request and response durations. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + @get:JvmName("clock") val clock: Clock, + /** + * The log level to use. + * + * Pass [LogLevel.fromEnv] to read from environment variables. + */ + @get:JvmName("level") val level: LogLevel, +) : HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + val loggingRequest = logRequest(request) + + val before = OffsetDateTime.now(clock) + val response = + try { + httpClient.execute(loggingRequest, requestOptions) + } catch (e: Throwable) { + logFailure(e, Duration.between(before, OffsetDateTime.now(clock))) + throw e + } + + val took = Duration.between(before, OffsetDateTime.now(clock)) + return logResponse(response, took) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val loggingRequest = logRequest(request) + + val before = OffsetDateTime.now(clock) + val future = + try { + httpClient.executeAsync(loggingRequest, requestOptions) + } catch (e: Throwable) { + logFailure(e, Duration.between(before, OffsetDateTime.now(clock))) + throw e + } + return future.handle { response, error -> + val took = Duration.between(before, OffsetDateTime.now(clock)) + if (error != null) { + logFailure(unwrapCompletionException(error), took) + throw error + } + logResponse(response, took) + } + } + + private fun logRequest(request: HttpRequest): HttpRequest { + if (!level.shouldLog(LogLevel.INFO)) { + return request + } + + System.err.println( + buildString { + append("--> ${request.method} ${request.url()}") + request.body?.let { + val length = it.contentLength() + append(if (length >= 0) " ($length-byte body)" else " (unknown-length body)") + } + } + ) + + if (!level.shouldLog(LogLevel.DEBUG)) { + return request + } + + logHeaders(request.headers) + + if (request.body == null) { + System.err.println("--> END ${request.method}") + System.err.println() + return request + } + + return request + .toBuilder() + .body(LoggingHttpRequestBody(request.method, request.body)) + .build() + } + + private fun logResponse(response: HttpResponse, took: Duration): HttpResponse { + if (!level.shouldLog(LogLevel.INFO)) { + return response + } + + val contentLength = response.headers().values("Content-Length").firstOrNull()?.toIntOrNull() + System.err.println( + "<-- ${response.statusCode()} (${ + buildString { + append(took.format()) + contentLength?.let { append(", $contentLength-byte body") } + } + })" + ) + + if (!level.shouldLog(LogLevel.DEBUG)) { + return response + } + + logHeaders(response.headers()) + return LoggingHttpResponse(response) + } + + private fun logFailure(error: Throwable, took: Duration) { + if (!level.shouldLog(LogLevel.ERROR)) { + return + } + + System.err.println( + buildString { + append("<-- !! ${error.javaClass.simpleName}") + error.message?.let { append(": $it") } + append(" (${took.format()})") + } + ) + } + + private fun unwrapCompletionException(error: Throwable): Throwable = + if (error is CompletionException && error.cause != null) error.cause!! else error + + private fun logHeaders(headers: Headers) = + headers.names().forEach { name -> + headers.values(name).forEach { value -> + System.err.println("$name: ${if (redactedHeaders.contains(name)) "██" else value}") + } + } + + override fun close() = httpClient.close() + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LoggingHttpClient]. + * + * The following fields are required: + * ```java + * .httpClient() + * .level() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LoggingHttpClient]. */ + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var redactedHeaders: Set = + setOf("authorization", "api-key", "x-api-key", "cookie", "set-cookie") + private var clock: Clock = Clock.systemUTC() + private var level: LogLevel? = null + + @JvmSynthetic + internal fun from(loggingHttpClient: LoggingHttpClient) = apply { + httpClient = loggingHttpClient.httpClient + redactedHeaders = loggingHttpClient.redactedHeaders + clock = loggingHttpClient.clock + level = loggingHttpClient.level + } + + /** The underlying [HttpClient] for making requests. */ + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + + /** + * Sensitive headers to redact from logs. + * + * Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie")`. + */ + fun redactedHeaders(redactedHeaders: Set) = apply { + this.redactedHeaders = redactedHeaders + } + + /** + * The clock to use for measuring request and response durations. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { this.clock = clock } + + /** + * The log level to use. + * + * Pass [LogLevel.fromEnv] to read from environment variables. + */ + fun level(level: LogLevel) = apply { this.level = level } + + /** + * Returns an immutable instance of [LoggingHttpClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * .level() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LoggingHttpClient = + LoggingHttpClient( + checkRequired("httpClient", httpClient), + redactedHeaders.toSortedSet(String.CASE_INSENSITIVE_ORDER).toImmutable(), + clock, + checkRequired("level", level), + ) + } +} + +/** + * An [HttpRequestBody] wrapper that delegates to [body] while also logging line by line as it's + * written. + * + * The logging occurs in a streaming manner with minimal buffering. + */ +private class LoggingHttpRequestBody( + private val method: HttpMethod, + private val body: HttpRequestBody, +) : HttpRequestBody { + + private val charset by lazy { parseCharset(body.contentType()) } + + override fun writeTo(outputStream: OutputStream) { + val loggingOutputStream = LoggingOutputStream(outputStream, charset) + body.writeTo(loggingOutputStream) + + loggingOutputStream.flush() + System.err.println("--> END $method (${loggingOutputStream.writeCount()}-byte body)") + System.err.println() + } + + override fun contentType(): String? = body.contentType() + + override fun contentLength(): Long = body.contentLength() + + override fun repeatable(): Boolean = body.repeatable() + + override fun close() = body.close() +} + +/** + * An [OutputStream] wrapper that delegates to [outputStream] while also logging bytes line by line + * as it's written to. + * + * The written content is assumed to be in the given [charset] and the logging occurs in a streaming + * manner with minimal buffering. + */ +private class LoggingOutputStream(private val outputStream: OutputStream, charset: Charset?) : + OutputStream() { + + private val buffer = LoggingBuffer(charset) + + fun writeCount() = buffer.writeCount() + + override fun write(b: Int) { + outputStream.write(b) + buffer.write(b) + } + + override fun write(b: ByteArray, off: Int, len: Int) { + outputStream.write(b, off, len) + for (i in off until off + len) { + buffer.write(b[i].toInt() and 0xFF) + } + } + + /** Prints any currently buffered content. */ + override fun flush() { + buffer.flush() + outputStream.flush() + } + + override fun close() = outputStream.close() +} + +/** + * An [HttpResponse] wrapper that delegates to [response] while also logging line-by-line as it's + * read. + * + * The logging occurs in a streaming manner with minimal buffering. + */ +private class LoggingHttpResponse(private val response: HttpResponse) : HttpResponse { + + private val loggingBody: Lazy = lazy { + LoggingInputStream( + response.body(), + parseCharset(response.headers().values("Content-Type").firstOrNull()), + ) + } + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = loggingBody.value + + override fun close() { + if (loggingBody.isInitialized()) { + loggingBody.value.close() + } + response.close() + } +} + +/** + * An [InputStream] wrapper that delegates to [inputStream] while also logging bytes line by line as + * it's read. + * + * The contents of [inputStream] are assumed to be in the given [charset] and the logging occurs in + * a streaming manner with minimal buffering. + */ +private class LoggingInputStream(private val inputStream: InputStream, charset: Charset?) : + InputStream() { + + private var isDone = false + private val buffer = LoggingBuffer(charset) + + override fun read(): Int { + if (isDone) { + return -1 + } + + val b = inputStream.read() + + if (b == -1) { + markDone() + return b + } + + buffer.write(b) + return b + } + + override fun read(b: ByteArray, off: Int, len: Int): Int { + if (isDone) { + return -1 + } + + val bytesRead = inputStream.read(b, off, len) + + if (bytesRead == -1) { + markDone() + return bytesRead + } + + for (i in off until off + bytesRead) { + buffer.write(b[i].toInt() and 0xFF) + } + return bytesRead + } + + override fun close() { + if (!isDone) { + markDone(closedEarly = true) + } + inputStream.close() + } + + private fun markDone(closedEarly: Boolean = false) { + isDone = true + buffer.flush() + val suffix = if (closedEarly) ", closed early" else "" + System.err.println("<-- END HTTP (${buffer.writeCount()}-byte body$suffix)") + System.err.println() + } +} + +/** + * A byte buffer that prints line by line, using the given [charset], as bytes are written to it. + * + * When [charset] is `null`, the buffer performs an upfront check to detect binary content. If + * non-whitespace ISO control characters are found in the first [PROBABLY_UTF8_CODE_POINT_LIMIT] + * code points, body logging is suppressed entirely. + */ +private class LoggingBuffer(charset: Charset?) { + + private val charset = charset ?: StandardCharsets.UTF_8 + + private val decoder: CharsetDecoder = + this.charset + .newDecoder() + .onMalformedInput(CodingErrorAction.REPORT) + .onUnmappableCharacter(CodingErrorAction.REPORT) + private var writeCount = 0 + private val buffer = ByteArrayOutputStream(128) + + /** + * Whether logging has been suppressed because the content doesn't appear to be readable text. + * + * This is only set when [charset] is `null` and the content fails the [isProbablyUtf8] check. + */ + private var suppressed = false + + /** + * Bytes accumulated for the [isProbablyUtf8] check before any lines are printed. + * + * Once the check passes (or [charset] is non-null), this is set to `null` and bytes flow + * directly to [buffer]. + */ + private var prefetchBuffer: ByteArrayOutputStream? = + if (charset != null) null else ByteArrayOutputStream(128) + + fun writeCount() = writeCount + + fun write(b: Int) { + if (writeCount == 0) { + // Print a newline before we start printing anything to separate the printed content + // from previous content. + System.err.println() + } + + writeCount++ + + if (suppressed) { + return + } + + val prefetch = prefetchBuffer + if (prefetch != null) { + prefetch.write(b) + // Continue accumulating until we have enough bytes to decide. + if (prefetch.size() < PROBABLY_UTF8_BYTE_LIMIT && b != '\n'.code) { + return + } + // We have enough bytes. Check if the content is probably UTF-8. + prefetchBuffer = null + val bytes = prefetch.toByteArray() + if (!isProbablyUtf8(bytes)) { + suppressed = true + System.err.println("(binary body omitted)") + return + } + // Content looks like UTF-8. Feed the accumulated bytes into the normal buffer. + for (byte in bytes) { + writeToBuffer(byte.toInt() and 0xFF) + } + return + } + + writeToBuffer(b) + } + + private fun writeToBuffer(b: Int) { + if (b == '\n'.code) { + flush() + return + } + + buffer.write(b) + } + + /** Prints any currently buffered content. */ + fun flush() { + if (suppressed) { + return + } + + // If we still have a prefetch buffer when flush is called (body was shorter than the + // limit), run the check now. + val prefetch = prefetchBuffer + if (prefetch != null) { + prefetchBuffer = null + val bytes = prefetch.toByteArray() + if (bytes.isEmpty()) { + return + } + if (!isProbablyUtf8(bytes)) { + suppressed = true + System.err.println("(binary body omitted)") + return + } + for (byte in bytes) { + writeToBuffer(byte.toInt() and 0xFF) + } + } + + if (buffer.size() == 0) { + return + } + + val line = + try { + decoder.decode(ByteBuffer.wrap(buffer.toByteArray())) + } catch (e: CharacterCodingException) { + "(omitted line is not valid $charset)" + } + buffer.reset() + System.err.println(line) + } +} + +/** The maximum number of code points to sample when checking if content is probably UTF-8. */ +private const val PROBABLY_UTF8_CODE_POINT_LIMIT = 64 + +/** + * The maximum number of bytes to accumulate before running the [isProbablyUtf8] check. UTF-8 code + * points are at most 4 bytes, so this accommodates [PROBABLY_UTF8_CODE_POINT_LIMIT] code points. + */ +private const val PROBABLY_UTF8_BYTE_LIMIT = PROBABLY_UTF8_CODE_POINT_LIMIT * 4 + +/** + * Returns `true` if the given [bytes] probably contain human-readable UTF-8 text. + * + * Decodes up to [PROBABLY_UTF8_CODE_POINT_LIMIT] code points and returns `false` if any + * non-whitespace ISO control characters are found, or if the bytes are not valid UTF-8. + */ +private fun isProbablyUtf8(bytes: ByteArray): Boolean { + try { + val decoder = + StandardCharsets.UTF_8.newDecoder() + .onMalformedInput(CodingErrorAction.REPORT) + .onUnmappableCharacter(CodingErrorAction.REPORT) + val charBuffer = decoder.decode(ByteBuffer.wrap(bytes)) + var codePointCount = 0 + var i = 0 + while (i < charBuffer.length && codePointCount < PROBABLY_UTF8_CODE_POINT_LIMIT) { + val codePoint = Character.codePointAt(charBuffer, i) + if (Character.isISOControl(codePoint) && !Character.isWhitespace(codePoint)) { + return false + } + i += Character.charCount(codePoint) + codePointCount++ + } + return true + } catch (e: CharacterCodingException) { + return false + } +} + +/** Returns the [Charset] in the given [contentType] string, or `null` if unspecified. */ +private fun parseCharset(contentType: String?): Charset? = + contentType + ?.split(";") + ?.drop(1) + ?.map { it.trim() } + ?.firstOrNull { it.startsWith("charset=", ignoreCase = true) } + ?.substringAfter("=") + ?.trim() + ?.removeSurrounding("\"") + ?.let { runCatching { charset(it) }.getOrNull() } + +/** Formats the [Duration] into a string like "1m 40s 467ms". */ +private fun Duration.format(): String = + toKotlinDuration().toComponents { days, hours, minutes, seconds, nanoseconds -> + buildString { + val milliseconds = nanoseconds / 1_000_000 + if (days > 0) { + append("${days}d") + } + if (hours > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${hours}h") + } + if (minutes > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${minutes}m") + } + if (seconds > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${seconds}s") + } + if (milliseconds > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${milliseconds}ms") + } + + if (isEmpty()) { + append("0s") + } + } + } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/ProxyAuthenticator.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/ProxyAuthenticator.kt new file mode 100644 index 000000000..cb2fbd5ab --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/ProxyAuthenticator.kt @@ -0,0 +1,59 @@ +package com.withorb.api.core.http + +import java.net.Proxy +import java.nio.charset.Charset +import java.nio.charset.StandardCharsets +import java.util.Base64 +import java.util.Optional + +/** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication Required`. + * + * Implementations inspect the 407 [response] (typically its `Proxy-Authenticate` header) and return + * the request to retry with a `Proxy-Authorization` header set, or [Optional.empty] to abandon + * authentication and surface the 407 to the caller. + * + * Implementations must be thread-safe; they may be invoked concurrently from multiple HTTP calls. + */ +fun interface ProxyAuthenticator { + + /** + * @param proxy the proxy that produced the challenge, or [Proxy.NO_PROXY] if the route is not + * yet established + * @param request the request that produced [response] + * @param response the 407 challenge response + * @return the retry request to send (typically [request] with a `Proxy-Authorization` header + * added), or [Optional.empty] to abandon authentication + */ + fun authenticate( + proxy: Proxy, + request: HttpRequest, + response: HttpResponse, + ): Optional + + companion object { + + /** + * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the ISO-8859-1 + * charset. + */ + @JvmStatic + fun basic(username: String, password: String): ProxyAuthenticator = + basic(username, password, StandardCharsets.ISO_8859_1) + + /** + * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the given [charset]. + */ + @JvmStatic + fun basic(username: String, password: String, charset: Charset): ProxyAuthenticator { + val token = + Base64.getEncoder().encodeToString("$username:$password".toByteArray(charset)) + val headerValue = "Basic $token" + return ProxyAuthenticator { _, request, _ -> + Optional.of( + request.toBuilder().putHeader("Proxy-Authorization", headerValue).build() + ) + } + } + } +} 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 6bd384bc4..22841dcf3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/RetryingHttpClient.kt @@ -1,3 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + package com.withorb.api.core.http import com.withorb.api.core.DefaultSleeper @@ -199,7 +201,7 @@ private constructor( ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) ?: try { - ChronoUnit.MILLIS.between( + ChronoUnit.NANOS.between( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, @@ -212,13 +214,8 @@ private constructor( } } ?.let { retryAfterNanos -> - // If the API asks us to wait a certain amount of time (and it's a reasonable - // amount), just - // do what it says. - val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) - if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { - return retryAfter - } + // If the API asks us to wait a certain amount of time, do what it says. + return Duration.ofNanos(retryAfterNanos.toLong()) } // Apply exponential backoff, but not more than the max. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt index 157ea6dd1..ca0378ea1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/BadRequestException.kt @@ -5,12 +5,16 @@ package com.withorb.api.errors import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers +import com.withorb.api.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class BadRequestException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OrbServiceException("400: $body", cause) { + OrbServiceException( + "400: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 400 diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/InternalServerException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/InternalServerException.kt index ad38f2699..f7232b72e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/InternalServerException.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/InternalServerException.kt @@ -5,6 +5,7 @@ package com.withorb.api.errors import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers +import com.withorb.api.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -14,7 +15,11 @@ private constructor( private val headers: Headers, private val body: JsonValue, cause: Throwable?, -) : OrbServiceException("$statusCode: $body", cause) { +) : + OrbServiceException( + "$statusCode: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = statusCode diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt index f059ba106..a819cf2d9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/NotFoundException.kt @@ -5,12 +5,16 @@ package com.withorb.api.errors import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers +import com.withorb.api.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class NotFoundException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OrbServiceException("404: $body", cause) { + OrbServiceException( + "404: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 404 diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt index 774d2ae37..48085c283 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/PermissionDeniedException.kt @@ -5,12 +5,16 @@ package com.withorb.api.errors import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers +import com.withorb.api.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class PermissionDeniedException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OrbServiceException("403: $body", cause) { + OrbServiceException( + "403: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 403 diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt index 536ea6ed1..f9d68fd4e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/RateLimitException.kt @@ -5,12 +5,16 @@ package com.withorb.api.errors import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers +import com.withorb.api.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class RateLimitException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OrbServiceException("429: $body", cause) { + OrbServiceException( + "429: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 429 diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt index 6ac99c31b..4277108d1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnauthorizedException.kt @@ -5,12 +5,16 @@ package com.withorb.api.errors import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers +import com.withorb.api.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class UnauthorizedException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OrbServiceException("401: $body", cause) { + OrbServiceException( + "401: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 401 diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnexpectedStatusCodeException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnexpectedStatusCodeException.kt index 75648438a..e66648e6f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnexpectedStatusCodeException.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnexpectedStatusCodeException.kt @@ -5,6 +5,7 @@ package com.withorb.api.errors import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers +import com.withorb.api.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -14,7 +15,11 @@ private constructor( private val headers: Headers, private val body: JsonValue, cause: Throwable?, -) : OrbServiceException("$statusCode: $body", cause) { +) : + OrbServiceException( + "$statusCode: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = statusCode diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt index 51ad3846a..00e45bd7f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/UnprocessableEntityException.kt @@ -5,12 +5,16 @@ package com.withorb.api.errors import com.withorb.api.core.JsonValue import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers +import com.withorb.api.core.jsonMapper import java.util.Optional import kotlin.jvm.optionals.getOrNull class UnprocessableEntityException private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : - OrbServiceException("422: $body", cause) { + OrbServiceException( + "422: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}", + cause, + ) { override fun statusCode(): Int = 422 diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt index bfbf6c224..faf36a35e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AccountingProviderConfig.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing @@ -14,12 +15,13 @@ import com.withorb.api.core.checkRequired import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull class AccountingProviderConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val externalProviderId: JsonField, - private val providerType: JsonField, + private val providerType: JsonField, private val additionalProperties: MutableMap, ) { @@ -30,7 +32,7 @@ private constructor( externalProviderId: JsonField = JsonMissing.of(), @JsonProperty("provider_type") @ExcludeMissing - providerType: JsonField = JsonMissing.of(), + providerType: JsonField = JsonMissing.of(), ) : this(externalProviderId, providerType, mutableMapOf()) /** @@ -43,7 +45,7 @@ private constructor( * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun providerType(): String = providerType.getRequired("provider_type") + fun providerType(): ProviderType = providerType.getRequired("provider_type") /** * Returns the raw JSON value of [externalProviderId]. @@ -62,7 +64,7 @@ private constructor( */ @JsonProperty("provider_type") @ExcludeMissing - fun _providerType(): JsonField = providerType + fun _providerType(): JsonField = providerType @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -94,7 +96,7 @@ private constructor( class Builder internal constructor() { private var externalProviderId: JsonField? = null - private var providerType: JsonField? = null + private var providerType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -118,16 +120,16 @@ private constructor( this.externalProviderId = externalProviderId } - fun providerType(providerType: String) = providerType(JsonField.of(providerType)) + fun providerType(providerType: ProviderType) = providerType(JsonField.of(providerType)) /** * Sets [Builder.providerType] to an arbitrary JSON value. * - * You should usually call [Builder.providerType] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.providerType] with a well-typed [ProviderType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun providerType(providerType: JsonField) = apply { + fun providerType(providerType: JsonField) = apply { this.providerType = providerType } @@ -173,13 +175,21 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): AccountingProviderConfig = apply { if (validated) { return@apply } externalProviderId() - providerType() + providerType().validate() validated = true } @@ -199,7 +209,143 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (externalProviderId.asKnown().isPresent) 1 else 0) + - (if (providerType.asKnown().isPresent) 1 else 0) + (providerType.asKnown().getOrNull()?.validity() ?: 0) + + class ProviderType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val QUICKBOOKS = of("quickbooks") + + @JvmField val NETSUITE = of("netsuite") + + @JvmStatic fun of(value: String) = ProviderType(JsonField.of(value)) + } + + /** An enum containing [ProviderType]'s known values. */ + enum class Known { + QUICKBOOKS, + NETSUITE, + } + + /** + * An enum containing [ProviderType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ProviderType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + QUICKBOOKS, + NETSUITE, + /** + * An enum member indicating that [ProviderType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + QUICKBOOKS -> Value.QUICKBOOKS + NETSUITE -> Value.NETSUITE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + QUICKBOOKS -> Known.QUICKBOOKS + NETSUITE -> Known.NETSUITE + else -> throw OrbInvalidDataException("Unknown ProviderType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ProviderType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Address.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Address.kt index de9c14aed..14f1b5584 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Address.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Address.kt @@ -300,6 +300,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Address = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt index 9dbc4e7fe..18803360c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInput.kt @@ -275,6 +275,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): AddressInput = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt index 17115a571..19246cee9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentInterval.kt @@ -335,6 +335,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): AdjustmentInterval = apply { if (validated) { return@apply @@ -419,6 +427,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitUsageDiscount(PlanPhaseUsageDiscountAdjustment usageDiscount) { + * return Optional.of(usageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) @@ -431,6 +468,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt index 342db5eb0..6a70fa987 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlock.kt @@ -263,6 +263,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): AffectedBlock = apply { if (validated) { return@apply @@ -497,6 +505,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -636,6 +653,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -765,6 +792,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt index 132a3db87..3cb77d5d4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCost.kt @@ -292,6 +292,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): AggregatedCost = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt index f35084b4a..05f58ec8a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt @@ -41,6 +41,10 @@ private constructor( private val thresholds: JsonField>, private val type: JsonField, private val balanceAlertStatus: JsonField>, + private val groupingKeys: JsonField>, + private val licenseType: JsonField, + private val priceFilters: JsonField>, + private val thresholdOverrides: JsonField>, private val additionalProperties: MutableMap, ) { @@ -67,6 +71,18 @@ private constructor( @JsonProperty("balance_alert_status") @ExcludeMissing balanceAlertStatus: JsonField> = JsonMissing.of(), + @JsonProperty("grouping_keys") + @ExcludeMissing + groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), + @JsonProperty("price_filters") + @ExcludeMissing + priceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("threshold_overrides") + @ExcludeMissing + thresholdOverrides: JsonField> = JsonMissing.of(), ) : this( id, createdAt, @@ -79,6 +95,10 @@ private constructor( thresholds, type, balanceAlertStatus, + groupingKeys, + licenseType, + priceFilters, + thresholdOverrides, mutableMapOf(), ) @@ -171,6 +191,42 @@ private constructor( fun balanceAlertStatus(): Optional> = balanceAlertStatus.getOptional("balance_alert_status") + /** + * The property keys to group cost alerts by. Only present for cost alerts with grouping + * enabled. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + + /** + * Minified license type for alert serialization. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + + /** + * Filters scoping which prices are included in grouped cost alert evaluation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun priceFilters(): Optional> = priceFilters.getOptional("price_filters") + + /** + * Per-group threshold overrides. Each override maps a specific combination of grouping_keys + * values to a replacement threshold list. Only present for grouped cost alerts that have at + * least one override. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun thresholdOverrides(): Optional> = + thresholdOverrides.getOptional("threshold_overrides") + /** * Returns the raw JSON value of [id]. * @@ -259,6 +315,43 @@ private constructor( @ExcludeMissing fun _balanceAlertStatus(): JsonField> = balanceAlertStatus + /** + * Returns the raw JSON value of [groupingKeys]. + * + * Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_keys") + @ExcludeMissing + fun _groupingKeys(): JsonField> = groupingKeys + + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + + /** + * Returns the raw JSON value of [priceFilters]. + * + * Unlike [priceFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_filters") + @ExcludeMissing + fun _priceFilters(): JsonField> = priceFilters + + /** + * Returns the raw JSON value of [thresholdOverrides]. + * + * Unlike [thresholdOverrides], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("threshold_overrides") + @ExcludeMissing + fun _thresholdOverrides(): JsonField> = thresholdOverrides + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -307,6 +400,10 @@ private constructor( private var thresholds: JsonField>? = null private var type: JsonField? = null private var balanceAlertStatus: JsonField>? = null + private var groupingKeys: JsonField>? = null + private var licenseType: JsonField = JsonMissing.of() + private var priceFilters: JsonField>? = null + private var thresholdOverrides: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -322,6 +419,10 @@ private constructor( thresholds = alert.thresholds.map { it.toMutableList() } type = alert.type balanceAlertStatus = alert.balanceAlertStatus.map { it.toMutableList() } + groupingKeys = alert.groupingKeys.map { it.toMutableList() } + licenseType = alert.licenseType + priceFilters = alert.priceFilters.map { it.toMutableList() } + thresholdOverrides = alert.thresholdOverrides.map { it.toMutableList() } additionalProperties = alert.additionalProperties.toMutableMap() } @@ -510,6 +611,125 @@ private constructor( } } + /** + * The property keys to group cost alerts by. Only present for cost alerts with grouping + * enabled. + */ + fun groupingKeys(groupingKeys: List?) = + groupingKeys(JsonField.ofNullable(groupingKeys)) + + /** Alias for calling [Builder.groupingKeys] with `groupingKeys.orElse(null)`. */ + fun groupingKeys(groupingKeys: Optional>) = + groupingKeys(groupingKeys.getOrNull()) + + /** + * Sets [Builder.groupingKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKeys(groupingKeys: JsonField>) = apply { + this.groupingKeys = groupingKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groupingKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupingKey(groupingKey: String) = apply { + groupingKeys = + (groupingKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("groupingKeys", it).add(groupingKey) + } + } + + /** Minified license type for alert serialization. */ + fun licenseType(licenseType: LicenseType?) = licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + + /** Filters scoping which prices are included in grouped cost alert evaluation. */ + fun priceFilters(priceFilters: List?) = + priceFilters(JsonField.ofNullable(priceFilters)) + + /** Alias for calling [Builder.priceFilters] with `priceFilters.orElse(null)`. */ + fun priceFilters(priceFilters: Optional>) = + priceFilters(priceFilters.getOrNull()) + + /** + * Sets [Builder.priceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.priceFilters] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun priceFilters(priceFilters: JsonField>) = apply { + this.priceFilters = priceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [PriceFilter] to [priceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPriceFilter(priceFilter: PriceFilter) = apply { + priceFilters = + (priceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("priceFilters", it).add(priceFilter) + } + } + + /** + * Per-group threshold overrides. Each override maps a specific combination of grouping_keys + * values to a replacement threshold list. Only present for grouped cost alerts that have at + * least one override. + */ + fun thresholdOverrides(thresholdOverrides: List?) = + thresholdOverrides(JsonField.ofNullable(thresholdOverrides)) + + /** + * Alias for calling [Builder.thresholdOverrides] with `thresholdOverrides.orElse(null)`. + */ + fun thresholdOverrides(thresholdOverrides: Optional>) = + thresholdOverrides(thresholdOverrides.getOrNull()) + + /** + * Sets [Builder.thresholdOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdOverrides] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun thresholdOverrides(thresholdOverrides: JsonField>) = apply { + this.thresholdOverrides = thresholdOverrides.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdOverride] to [thresholdOverrides]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThresholdOverride(thresholdOverride: ThresholdOverride) = apply { + thresholdOverrides = + (thresholdOverrides ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdOverrides", it).add(thresholdOverride) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -563,12 +783,24 @@ private constructor( checkRequired("thresholds", thresholds).map { it.toImmutable() }, checkRequired("type", type), (balanceAlertStatus ?: JsonMissing.of()).map { it.toImmutable() }, + (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + licenseType, + (priceFilters ?: JsonMissing.of()).map { it.toImmutable() }, + (thresholdOverrides ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Alert = apply { if (validated) { return@apply @@ -585,6 +817,10 @@ private constructor( thresholds().ifPresent { it.forEach { it.validate() } } type().validate() balanceAlertStatus().ifPresent { it.forEach { it.validate() } } + groupingKeys() + licenseType().ifPresent { it.validate() } + priceFilters().ifPresent { it.forEach { it.validate() } } + thresholdOverrides().ifPresent { it.forEach { it.validate() } } validated = true } @@ -613,7 +849,11 @@ private constructor( (subscription.asKnown().getOrNull()?.validity() ?: 0) + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + - (balanceAlertStatus.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (balanceAlertStatus.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) + + (priceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (thresholdOverrides.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) /** The metric the alert applies to. */ class Metric @@ -726,6 +966,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metric = apply { if (validated) { return@apply @@ -1008,6 +1257,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Plan = apply { if (validated) { return@apply @@ -1089,6 +1347,9 @@ private constructor( @JvmField val COST_EXCEEDED = of("cost_exceeded") + @JvmField + val LICENSE_BALANCE_THRESHOLD_REACHED = of("license_balance_threshold_reached") + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -1099,6 +1360,7 @@ private constructor( CREDIT_BALANCE_RECOVERED, USAGE_EXCEEDED, COST_EXCEEDED, + LICENSE_BALANCE_THRESHOLD_REACHED, } /** @@ -1116,6 +1378,7 @@ private constructor( CREDIT_BALANCE_RECOVERED, USAGE_EXCEEDED, COST_EXCEEDED, + LICENSE_BALANCE_THRESHOLD_REACHED, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1134,6 +1397,7 @@ private constructor( CREDIT_BALANCE_RECOVERED -> Value.CREDIT_BALANCE_RECOVERED USAGE_EXCEEDED -> Value.USAGE_EXCEEDED COST_EXCEEDED -> Value.COST_EXCEEDED + LICENSE_BALANCE_THRESHOLD_REACHED -> Value.LICENSE_BALANCE_THRESHOLD_REACHED else -> Value._UNKNOWN } @@ -1152,6 +1416,7 @@ private constructor( CREDIT_BALANCE_RECOVERED -> Known.CREDIT_BALANCE_RECOVERED USAGE_EXCEEDED -> Known.USAGE_EXCEEDED COST_EXCEEDED -> Known.COST_EXCEEDED + LICENSE_BALANCE_THRESHOLD_REACHED -> Known.LICENSE_BALANCE_THRESHOLD_REACHED else -> throw OrbInvalidDataException("Unknown Type: $value") } @@ -1169,6 +1434,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply @@ -1368,6 +1642,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BalanceAlertStatus = apply { if (validated) { return@apply @@ -1418,6 +1701,982 @@ private constructor( "BalanceAlertStatus{inAlert=$inAlert, thresholdValue=$thresholdValue, additionalProperties=$additionalProperties}" } + /** Minified license type for alert serialization. */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * 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(): LicenseType = + LicenseType(checkRequired("id", id), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LicenseType{id=$id, additionalProperties=$additionalProperties}" + } + + class PriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PriceFilter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceFilter: PriceFilter) = apply { + field = priceFilter.field + operator = priceFilter.operator + values = priceFilter.values.map { it.toMutableList() } + additionalProperties = priceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PriceFilter = + PriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PRICE_ID = of("price_id") + + @JvmField val ITEM_ID = of("item_id") + + @JvmField val PRICE_TYPE = of("price_type") + + @JvmField val CURRENCY = of("currency") + + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INCLUDES = of("includes") + + @JvmField val EXCLUDES = of("excludes") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** + * A per-group threshold override on a grouped cost alert. + * + * An empty `thresholds` list means the group is silenced (never fires). A non-empty list fully + * replaces the default thresholds for that group. + */ + class ThresholdOverride + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupValues: JsonField>, + private val thresholds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("group_values") + @ExcludeMissing + groupValues: JsonField> = JsonMissing.of(), + @JsonProperty("thresholds") + @ExcludeMissing + thresholds: JsonField> = JsonMissing.of(), + ) : this(groupValues, thresholds, mutableMapOf()) + + /** + * The values of the grouping keys that identify this group. The list length matches the + * alert's grouping_keys. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupValues(): List = groupValues.getRequired("group_values") + + /** + * The thresholds applied to this group. An empty list means the group is silenced. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun thresholds(): List = thresholds.getRequired("thresholds") + + /** + * Returns the raw JSON value of [groupValues]. + * + * Unlike [groupValues], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_values") + @ExcludeMissing + fun _groupValues(): JsonField> = groupValues + + /** + * Returns the raw JSON value of [thresholds]. + * + * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thresholds") + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ThresholdOverride]. + * + * The following fields are required: + * ```java + * .groupValues() + * .thresholds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdOverride]. */ + class Builder internal constructor() { + + private var groupValues: JsonField>? = null + private var thresholds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdOverride: ThresholdOverride) = apply { + groupValues = thresholdOverride.groupValues.map { it.toMutableList() } + thresholds = thresholdOverride.thresholds.map { it.toMutableList() } + additionalProperties = thresholdOverride.additionalProperties.toMutableMap() + } + + /** + * The values of the grouping keys that identify this group. The list length matches the + * alert's grouping_keys. + */ + fun groupValues(groupValues: List) = groupValues(JsonField.of(groupValues)) + + /** + * Sets [Builder.groupValues] to an arbitrary JSON value. + * + * You should usually call [Builder.groupValues] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupValues(groupValues: JsonField>) = apply { + this.groupValues = groupValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groupValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupValue(groupValue: String) = apply { + groupValues = + (groupValues ?: JsonField.of(mutableListOf())).also { + checkKnown("groupValues", it).add(groupValue) + } + } + + /** The thresholds applied to this group. An empty list means the group is silenced. */ + fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) + + /** + * Sets [Builder.thresholds] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } + } + + /** + * Adds a single [Threshold] to [thresholds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThreshold(threshold: Threshold) = apply { + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholds", it).add(threshold) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdOverride]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupValues() + * .thresholds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdOverride = + ThresholdOverride( + checkRequired("groupValues", groupValues).map { it.toImmutable() }, + checkRequired("thresholds", thresholds).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ThresholdOverride = apply { + if (validated) { + return@apply + } + + groupValues() + thresholds().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (groupValues.asKnown().getOrNull()?.size ?: 0) + + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdOverride && + groupValues == other.groupValues && + thresholds == other.thresholds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupValues, thresholds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdOverride{groupValues=$groupValues, thresholds=$thresholds, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1435,6 +2694,10 @@ private constructor( thresholds == other.thresholds && type == other.type && balanceAlertStatus == other.balanceAlertStatus && + groupingKeys == other.groupingKeys && + licenseType == other.licenseType && + priceFilters == other.priceFilters && + thresholdOverrides == other.thresholdOverrides && additionalProperties == other.additionalProperties } @@ -1451,6 +2714,10 @@ private constructor( thresholds, type, balanceAlertStatus, + groupingKeys, + licenseType, + priceFilters, + thresholdOverrides, additionalProperties, ) } @@ -1458,5 +2725,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, additionalProperties=$additionalProperties}" + "Alert{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, balanceAlertStatus=$balanceAlertStatus, groupingKeys=$groupingKeys, licenseType=$licenseType, priceFilters=$priceFilters, thresholdOverrides=$thresholdOverrides, additionalProperties=$additionalProperties}" } 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 23046502e..31b7856df 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 @@ -546,6 +546,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -692,6 +701,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply 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 e33329641..8d52e9869 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 @@ -555,6 +555,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -701,6 +710,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply 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 7329b98c4..ce907a9de 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 @@ -61,6 +61,14 @@ private constructor( */ fun type(): Type = body.type() + /** + * The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun groupingKeys(): Optional> = body.groupingKeys() + /** * The metric to track usage for. * @@ -69,6 +77,35 @@ private constructor( */ fun metricId(): Optional = body.metricId() + /** + * Filters to scope which prices are included in grouped cost alert evaluation. Supports + * filtering by price_id, item_id, or price_type with includes/excludes operators. Only + * applicable when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun priceFilters(): Optional> = body.priceFilters() + + /** + * The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun pricingUnitId(): Optional = body.pricingUnitId() + + /** + * Per-group threshold overrides. Each override maps a specific combination of grouping_keys + * values to a list of thresholds that fully replaces the default thresholds for that group. An + * empty thresholds list silences the group. Groups without an override use the default + * thresholds. Only applicable when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun thresholdOverrides(): Optional> = body.thresholdOverrides() + /** * Returns the raw JSON value of [thresholds]. * @@ -83,6 +120,13 @@ private constructor( */ fun _type(): JsonField = body._type() + /** + * Returns the raw JSON value of [groupingKeys]. + * + * Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _groupingKeys(): JsonField> = body._groupingKeys() + /** * Returns the raw JSON value of [metricId]. * @@ -90,6 +134,28 @@ private constructor( */ fun _metricId(): JsonField = body._metricId() + /** + * Returns the raw JSON value of [priceFilters]. + * + * Unlike [priceFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _priceFilters(): JsonField> = body._priceFilters() + + /** + * Returns the raw JSON value of [pricingUnitId]. + * + * Unlike [pricingUnitId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _pricingUnitId(): JsonField = body._pricingUnitId() + + /** + * Returns the raw JSON value of [thresholdOverrides]. + * + * Unlike [thresholdOverrides], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _thresholdOverrides(): JsonField> = body._thresholdOverrides() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -146,7 +212,10 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [thresholds] * - [type] + * - [groupingKeys] * - [metricId] + * - [priceFilters] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -182,6 +251,31 @@ private constructor( */ fun type(type: JsonField) = apply { body.type(type) } + /** The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. */ + fun groupingKeys(groupingKeys: List?) = apply { body.groupingKeys(groupingKeys) } + + /** Alias for calling [Builder.groupingKeys] with `groupingKeys.orElse(null)`. */ + fun groupingKeys(groupingKeys: Optional>) = + groupingKeys(groupingKeys.getOrNull()) + + /** + * Sets [Builder.groupingKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKeys(groupingKeys: JsonField>) = apply { + body.groupingKeys(groupingKeys) + } + + /** + * Adds a single [String] to [groupingKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupingKey(groupingKey: String) = apply { body.addGroupingKey(groupingKey) } + /** The metric to track usage for. */ fun metricId(metricId: String?) = apply { body.metricId(metricId) } @@ -196,6 +290,91 @@ private constructor( */ fun metricId(metricId: JsonField) = apply { body.metricId(metricId) } + /** + * Filters to scope which prices are included in grouped cost alert evaluation. Supports + * filtering by price_id, item_id, or price_type with includes/excludes operators. Only + * applicable when grouping_keys is set. + */ + fun priceFilters(priceFilters: List?) = apply { + body.priceFilters(priceFilters) + } + + /** Alias for calling [Builder.priceFilters] with `priceFilters.orElse(null)`. */ + fun priceFilters(priceFilters: Optional>) = + priceFilters(priceFilters.getOrNull()) + + /** + * Sets [Builder.priceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.priceFilters] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun priceFilters(priceFilters: JsonField>) = apply { + body.priceFilters(priceFilters) + } + + /** + * Adds a single [PriceFilter] to [priceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPriceFilter(priceFilter: PriceFilter) = apply { body.addPriceFilter(priceFilter) } + + /** The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. */ + fun pricingUnitId(pricingUnitId: String?) = apply { body.pricingUnitId(pricingUnitId) } + + /** Alias for calling [Builder.pricingUnitId] with `pricingUnitId.orElse(null)`. */ + fun pricingUnitId(pricingUnitId: Optional) = + pricingUnitId(pricingUnitId.getOrNull()) + + /** + * Sets [Builder.pricingUnitId] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnitId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pricingUnitId(pricingUnitId: JsonField) = apply { + body.pricingUnitId(pricingUnitId) + } + + /** + * Per-group threshold overrides. Each override maps a specific combination of grouping_keys + * values to a list of thresholds that fully replaces the default thresholds for that group. + * An empty thresholds list silences the group. Groups without an override use the default + * thresholds. Only applicable when grouping_keys is set. + */ + fun thresholdOverrides(thresholdOverrides: List?) = apply { + body.thresholdOverrides(thresholdOverrides) + } + + /** + * Alias for calling [Builder.thresholdOverrides] with `thresholdOverrides.orElse(null)`. + */ + fun thresholdOverrides(thresholdOverrides: Optional>) = + thresholdOverrides(thresholdOverrides.getOrNull()) + + /** + * Sets [Builder.thresholdOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdOverrides] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun thresholdOverrides(thresholdOverrides: JsonField>) = apply { + body.thresholdOverrides(thresholdOverrides) + } + + /** + * Adds a single [ThresholdOverride] to [thresholdOverrides]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThresholdOverride(thresholdOverride: ThresholdOverride) = apply { + body.addThresholdOverride(thresholdOverride) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -352,7 +531,11 @@ private constructor( private constructor( private val thresholds: JsonField>, private val type: JsonField, + private val groupingKeys: JsonField>, private val metricId: JsonField, + private val priceFilters: JsonField>, + private val pricingUnitId: JsonField, + private val thresholdOverrides: JsonField>, private val additionalProperties: MutableMap, ) { @@ -362,10 +545,31 @@ private constructor( @ExcludeMissing thresholds: JsonField> = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("grouping_keys") + @ExcludeMissing + groupingKeys: JsonField> = JsonMissing.of(), @JsonProperty("metric_id") @ExcludeMissing metricId: JsonField = JsonMissing.of(), - ) : this(thresholds, type, metricId, mutableMapOf()) + @JsonProperty("price_filters") + @ExcludeMissing + priceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("pricing_unit_id") + @ExcludeMissing + pricingUnitId: JsonField = JsonMissing.of(), + @JsonProperty("threshold_overrides") + @ExcludeMissing + thresholdOverrides: JsonField> = JsonMissing.of(), + ) : this( + thresholds, + type, + groupingKeys, + metricId, + priceFilters, + pricingUnitId, + thresholdOverrides, + mutableMapOf(), + ) /** * The thresholds that define the values at which the alert will be triggered. @@ -383,6 +587,14 @@ private constructor( */ fun type(): Type = type.getRequired("type") + /** + * The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + /** * The metric to track usage for. * @@ -391,6 +603,36 @@ private constructor( */ fun metricId(): Optional = metricId.getOptional("metric_id") + /** + * Filters to scope which prices are included in grouped cost alert evaluation. Supports + * filtering by price_id, item_id, or price_type with includes/excludes operators. Only + * applicable when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceFilters(): Optional> = priceFilters.getOptional("price_filters") + + /** + * The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pricingUnitId(): Optional = pricingUnitId.getOptional("pricing_unit_id") + + /** + * Per-group threshold overrides. Each override maps a specific combination of grouping_keys + * values to a list of thresholds that fully replaces the default thresholds for that group. + * An empty thresholds list silences the group. Groups without an override use the default + * thresholds. Only applicable when grouping_keys is set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun thresholdOverrides(): Optional> = + thresholdOverrides.getOptional("threshold_overrides") + /** * Returns the raw JSON value of [thresholds]. * @@ -407,6 +649,16 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [groupingKeys]. + * + * Unlike [groupingKeys], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_keys") + @ExcludeMissing + fun _groupingKeys(): JsonField> = groupingKeys + /** * Returns the raw JSON value of [metricId]. * @@ -414,6 +666,36 @@ private constructor( */ @JsonProperty("metric_id") @ExcludeMissing fun _metricId(): JsonField = metricId + /** + * Returns the raw JSON value of [priceFilters]. + * + * Unlike [priceFilters], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_filters") + @ExcludeMissing + fun _priceFilters(): JsonField> = priceFilters + + /** + * Returns the raw JSON value of [pricingUnitId]. + * + * Unlike [pricingUnitId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pricing_unit_id") + @ExcludeMissing + fun _pricingUnitId(): JsonField = pricingUnitId + + /** + * Returns the raw JSON value of [thresholdOverrides]. + * + * Unlike [thresholdOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold_overrides") + @ExcludeMissing + fun _thresholdOverrides(): JsonField> = thresholdOverrides + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -445,14 +727,22 @@ private constructor( private var thresholds: JsonField>? = null private var type: JsonField? = null + private var groupingKeys: JsonField>? = null private var metricId: JsonField = JsonMissing.of() + private var priceFilters: JsonField>? = null + private var pricingUnitId: JsonField = JsonMissing.of() + private var thresholdOverrides: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { thresholds = body.thresholds.map { it.toMutableList() } type = body.type + groupingKeys = body.groupingKeys.map { it.toMutableList() } metricId = body.metricId + priceFilters = body.priceFilters.map { it.toMutableList() } + pricingUnitId = body.pricingUnitId + thresholdOverrides = body.thresholdOverrides.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() } @@ -494,6 +784,39 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** + * The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + */ + fun groupingKeys(groupingKeys: List?) = + groupingKeys(JsonField.ofNullable(groupingKeys)) + + /** Alias for calling [Builder.groupingKeys] with `groupingKeys.orElse(null)`. */ + fun groupingKeys(groupingKeys: Optional>) = + groupingKeys(groupingKeys.getOrNull()) + + /** + * Sets [Builder.groupingKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKeys] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKeys(groupingKeys: JsonField>) = apply { + this.groupingKeys = groupingKeys.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groupingKeys]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupingKey(groupingKey: String) = apply { + groupingKeys = + (groupingKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("groupingKeys", it).add(groupingKey) + } + } + /** The metric to track usage for. */ fun metricId(metricId: String?) = metricId(JsonField.ofNullable(metricId)) @@ -509,6 +832,102 @@ private constructor( */ fun metricId(metricId: JsonField) = apply { this.metricId = metricId } + /** + * Filters to scope which prices are included in grouped cost alert evaluation. Supports + * filtering by price_id, item_id, or price_type with includes/excludes operators. Only + * applicable when grouping_keys is set. + */ + fun priceFilters(priceFilters: List?) = + priceFilters(JsonField.ofNullable(priceFilters)) + + /** Alias for calling [Builder.priceFilters] with `priceFilters.orElse(null)`. */ + fun priceFilters(priceFilters: Optional>) = + priceFilters(priceFilters.getOrNull()) + + /** + * Sets [Builder.priceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.priceFilters] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun priceFilters(priceFilters: JsonField>) = apply { + this.priceFilters = priceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [PriceFilter] to [priceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPriceFilter(priceFilter: PriceFilter) = apply { + priceFilters = + (priceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("priceFilters", it).add(priceFilter) + } + } + + /** + * The pricing unit to use for grouped cost alerts. Required when grouping_keys is set. + */ + fun pricingUnitId(pricingUnitId: String?) = + pricingUnitId(JsonField.ofNullable(pricingUnitId)) + + /** Alias for calling [Builder.pricingUnitId] with `pricingUnitId.orElse(null)`. */ + fun pricingUnitId(pricingUnitId: Optional) = + pricingUnitId(pricingUnitId.getOrNull()) + + /** + * Sets [Builder.pricingUnitId] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnitId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnitId(pricingUnitId: JsonField) = apply { + this.pricingUnitId = pricingUnitId + } + + /** + * Per-group threshold overrides. Each override maps a specific combination of + * grouping_keys values to a list of thresholds that fully replaces the default + * thresholds for that group. An empty thresholds list silences the group. Groups + * without an override use the default thresholds. Only applicable when grouping_keys is + * set. + */ + fun thresholdOverrides(thresholdOverrides: List?) = + thresholdOverrides(JsonField.ofNullable(thresholdOverrides)) + + /** + * Alias for calling [Builder.thresholdOverrides] with + * `thresholdOverrides.orElse(null)`. + */ + fun thresholdOverrides(thresholdOverrides: Optional>) = + thresholdOverrides(thresholdOverrides.getOrNull()) + + /** + * Sets [Builder.thresholdOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdOverrides] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdOverrides(thresholdOverrides: JsonField>) = apply { + this.thresholdOverrides = thresholdOverrides.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdOverride] to [thresholdOverrides]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThresholdOverride(thresholdOverride: ThresholdOverride) = apply { + thresholdOverrides = + (thresholdOverrides ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdOverrides", it).add(thresholdOverride) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -545,13 +964,26 @@ private constructor( Body( checkRequired("thresholds", thresholds).map { it.toImmutable() }, checkRequired("type", type), + (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, metricId, + (priceFilters ?: JsonMissing.of()).map { it.toImmutable() }, + pricingUnitId, + (thresholdOverrides ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -559,7 +991,11 @@ private constructor( thresholds().forEach { it.validate() } type().validate() + groupingKeys() metricId() + priceFilters().ifPresent { it.forEach { it.validate() } } + pricingUnitId() + thresholdOverrides().ifPresent { it.forEach { it.validate() } } validated = true } @@ -581,7 +1017,11 @@ private constructor( internal fun validity(): Int = (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (metricId.asKnown().isPresent) 1 else 0) + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (if (metricId.asKnown().isPresent) 1 else 0) + + (priceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (pricingUnitId.asKnown().isPresent) 1 else 0) + + (thresholdOverrides.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -591,18 +1031,31 @@ private constructor( return other is Body && thresholds == other.thresholds && type == other.type && + groupingKeys == other.groupingKeys && metricId == other.metricId && + priceFilters == other.priceFilters && + pricingUnitId == other.pricingUnitId && + thresholdOverrides == other.thresholdOverrides && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(thresholds, type, metricId, additionalProperties) + Objects.hash( + thresholds, + type, + groupingKeys, + metricId, + priceFilters, + pricingUnitId, + thresholdOverrides, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{thresholds=$thresholds, type=$type, metricId=$metricId, additionalProperties=$additionalProperties}" + "Body{thresholds=$thresholds, type=$type, groupingKeys=$groupingKeys, metricId=$metricId, priceFilters=$priceFilters, pricingUnitId=$pricingUnitId, thresholdOverrides=$thresholdOverrides, additionalProperties=$additionalProperties}" } /** The type of alert to create. This must be a valid alert type. */ @@ -692,6 +1145,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply @@ -730,6 +1192,823 @@ private constructor( override fun toString() = value.toString() } + class PriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PriceFilter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceFilter: PriceFilter) = apply { + field = priceFilter.field + operator = priceFilter.operator + values = priceFilter.values.map { it.toMutableList() } + additionalProperties = priceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PriceFilter = + PriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PRICE_ID = of("price_id") + + @JvmField val ITEM_ID = of("item_id") + + @JvmField val PRICE_TYPE = of("price_type") + + @JvmField val CURRENCY = of("currency") + + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INCLUDES = of("includes") + + @JvmField val EXCLUDES = of("excludes") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** + * Per-group threshold override on a grouped cost alert. + * - An empty `thresholds` list silences alerts for this group (never fires). + * - A non-empty list fully replaces the default thresholds for this group. + */ + class ThresholdOverride + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupValues: JsonField>, + private val thresholds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("group_values") + @ExcludeMissing + groupValues: JsonField> = JsonMissing.of(), + @JsonProperty("thresholds") + @ExcludeMissing + thresholds: JsonField> = JsonMissing.of(), + ) : this(groupValues, thresholds, mutableMapOf()) + + /** + * The values of the grouping keys that identify this group. The list length must match the + * alert's grouping_keys, and values appear in the same order as grouping_keys. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupValues(): List = groupValues.getRequired("group_values") + + /** + * The thresholds to apply to this group. An empty list silences alerts for this group. A + * non-empty list fully replaces the default thresholds for this group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun thresholds(): List = thresholds.getRequired("thresholds") + + /** + * Returns the raw JSON value of [groupValues]. + * + * Unlike [groupValues], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("group_values") + @ExcludeMissing + fun _groupValues(): JsonField> = groupValues + + /** + * Returns the raw JSON value of [thresholds]. + * + * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thresholds") + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ThresholdOverride]. + * + * The following fields are required: + * ```java + * .groupValues() + * .thresholds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdOverride]. */ + class Builder internal constructor() { + + private var groupValues: JsonField>? = null + private var thresholds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdOverride: ThresholdOverride) = apply { + groupValues = thresholdOverride.groupValues.map { it.toMutableList() } + thresholds = thresholdOverride.thresholds.map { it.toMutableList() } + additionalProperties = thresholdOverride.additionalProperties.toMutableMap() + } + + /** + * The values of the grouping keys that identify this group. The list length must match + * the alert's grouping_keys, and values appear in the same order as grouping_keys. + */ + fun groupValues(groupValues: List) = groupValues(JsonField.of(groupValues)) + + /** + * Sets [Builder.groupValues] to an arbitrary JSON value. + * + * You should usually call [Builder.groupValues] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupValues(groupValues: JsonField>) = apply { + this.groupValues = groupValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [groupValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupValue(groupValue: String) = apply { + groupValues = + (groupValues ?: JsonField.of(mutableListOf())).also { + checkKnown("groupValues", it).add(groupValue) + } + } + + /** + * The thresholds to apply to this group. An empty list silences alerts for this group. + * A non-empty list fully replaces the default thresholds for this group. + */ + fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) + + /** + * Sets [Builder.thresholds] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } + } + + /** + * Adds a single [Threshold] to [thresholds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThreshold(threshold: Threshold) = apply { + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholds", it).add(threshold) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdOverride]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupValues() + * .thresholds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdOverride = + ThresholdOverride( + checkRequired("groupValues", groupValues).map { it.toImmutable() }, + checkRequired("thresholds", thresholds).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ThresholdOverride = apply { + if (validated) { + return@apply + } + + groupValues() + thresholds().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (groupValues.asKnown().getOrNull()?.size ?: 0) + + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdOverride && + groupValues == other.groupValues && + thresholds == other.thresholds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupValues, thresholds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdOverride{groupValues=$groupValues, thresholds=$thresholds, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt index bfa4b2799..e8a5bf738 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageResponse.kt @@ -185,6 +185,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): AlertListPageResponse = apply { if (validated) { return@apply 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 96f3f152b..5961529f9 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 @@ -412,6 +412,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt index ab6fd5234..9116b231d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Allocation.kt @@ -27,6 +27,7 @@ private constructor( private val currency: JsonField, private val customExpiration: JsonField, private val filters: JsonField>, + private val licenseTypeId: JsonField, private val additionalProperties: MutableMap, ) { @@ -39,8 +40,13 @@ private constructor( @JsonProperty("custom_expiration") @ExcludeMissing customExpiration: JsonField = JsonMissing.of(), - @JsonProperty("filters") @ExcludeMissing filters: JsonField> = JsonMissing.of(), - ) : this(allowsRollover, currency, customExpiration, filters, mutableMapOf()) + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + ) : this(allowsRollover, currency, customExpiration, filters, licenseTypeId, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -67,6 +73,12 @@ private constructor( */ fun filters(): Optional> = filters.getOptional("filters") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * Returns the raw JSON value of [allowsRollover]. * @@ -100,6 +112,15 @@ private constructor( */ @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -134,6 +155,7 @@ private constructor( private var currency: JsonField? = null private var customExpiration: JsonField? = null private var filters: JsonField>? = null + private var licenseTypeId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -142,6 +164,7 @@ private constructor( currency = allocation.currency customExpiration = allocation.customExpiration filters = allocation.filters.map { it.toMutableList() } + licenseTypeId = allocation.licenseTypeId additionalProperties = allocation.additionalProperties.toMutableMap() } @@ -211,6 +234,24 @@ private constructor( } } + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -250,12 +291,21 @@ private constructor( checkRequired("currency", currency), checkRequired("customExpiration", customExpiration), (filters ?: JsonMissing.of()).map { it.toImmutable() }, + licenseTypeId, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Allocation = apply { if (validated) { return@apply @@ -265,6 +315,7 @@ private constructor( currency() customExpiration().ifPresent { it.validate() } filters().ifPresent { it.forEach { it.validate() } } + licenseTypeId() validated = true } @@ -286,7 +337,8 @@ private constructor( (if (allowsRollover.asKnown().isPresent) 1 else 0) + (if (currency.asKnown().isPresent) 1 else 0) + (customExpiration.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -490,6 +542,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -629,6 +690,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -758,6 +829,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -828,15 +909,23 @@ private constructor( currency == other.currency && customExpiration == other.customExpiration && filters == other.filters && + licenseTypeId == other.licenseTypeId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(allowsRollover, currency, customExpiration, filters, additionalProperties) + Objects.hash( + allowsRollover, + currency, + customExpiration, + filters, + licenseTypeId, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Allocation{allowsRollover=$allowsRollover, currency=$currency, customExpiration=$customExpiration, filters=$filters, additionalProperties=$additionalProperties}" + "Allocation{allowsRollover=$allowsRollover, currency=$currency, customExpiration=$customExpiration, filters=$filters, licenseTypeId=$licenseTypeId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt index 9e161e9e2..6fff8acbd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmendmentLedgerEntry.kt @@ -574,6 +574,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): AmendmentLedgerEntry = apply { if (validated) { return@apply @@ -713,6 +721,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryStatus = apply { if (validated) { return@apply @@ -833,6 +850,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryType = apply { if (validated) { return@apply @@ -934,6 +960,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt index 9a03097b9..f047538a2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt @@ -322,6 +322,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): AmountDiscount = apply { if (validated) { return@apply @@ -439,6 +447,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -679,6 +696,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -818,6 +844,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -947,6 +983,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt index affadf3b6..8dc52cf21 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountInterval.kt @@ -373,6 +373,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): AmountDiscountInterval = apply { if (validated) { return@apply @@ -492,6 +500,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -732,6 +749,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -871,6 +897,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1000,6 +1036,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt index c52a84d0c..e4726c97a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaCreatePlanVersionParams.kt @@ -1095,6 +1095,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1437,6 +1446,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AddAdjustment = apply { if (validated) { return@apply @@ -1513,6 +1531,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentageDiscount != null -> @@ -1526,6 +1574,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -1758,6 +1816,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, private val additionalProperties: MutableMap, @@ -1768,11 +1827,14 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(allocationPrice, licenseAllocationPrice, planPhaseOrder, price, mutableMapOf()) /** * The allocation price to add to the plan. @@ -1783,6 +1845,15 @@ private constructor( fun allocationPrice(): Optional = allocationPrice.getOptional("allocation_price") + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + /** * The phase to add this price to. * @@ -1809,6 +1880,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -1848,6 +1929,7 @@ private constructor( class Builder internal constructor() { private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1855,6 +1937,7 @@ private constructor( @JvmSynthetic internal fun from(addPrice: AddPrice) = apply { allocationPrice = addPrice.allocationPrice + licenseAllocationPrice = addPrice.licenseAllocationPrice planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price additionalProperties = addPrice.additionalProperties.toMutableMap() @@ -1879,6 +1962,29 @@ private constructor( this.allocationPrice = allocationPrice } + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -1981,6 +2087,13 @@ private constructor( fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -2069,6 +2182,16 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: NewPlanMinimumCompositePrice) = price(Price.ofMinimumComposite(minimumComposite)) @@ -2106,6 +2229,7 @@ private constructor( fun build(): AddPrice = AddPrice( allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties.toMutableMap(), @@ -2114,12 +2238,22 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AddPrice = apply { if (validated) { return@apply } allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } planPhaseOrder() price().ifPresent { it.validate() } validated = true @@ -2142,518 +2276,1184 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + /** The license allocation price to add to the plan. */ + class LicenseAllocationPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonField, + private val name: JsonField, + private val unitConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - fun tiered(): Optional = Optional.ofNullable(tiered) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun bulk(): Optional = Optional.ofNullable(bulk) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + /** + * License allocations to associate with this price. Each entry defines a per-license + * credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") - fun package_(): Optional = Optional.ofNullable(package_) + /** + * The pricing model type + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun modelType(): ModelType = modelType.getRequired("model_type") - fun matrix(): Optional = Optional.ofNullable(matrix) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - fun groupedWithProratedMinimum(): Optional = - Optional.ofNullable(groupedWithProratedMinimum) + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - fun groupedWithMeteredMinimum(): Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - fun groupedWithMinMaxThresholds(): Optional = - Optional.ofNullable(groupedWithMinMaxThresholds) + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + /** + * 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 - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig - fun cumulativeGroupedAllocation(): Optional = - Optional.ofNullable(cumulativeGroupedAllocation) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun minimumComposite(): Optional = - Optional.ofNullable(minimumComposite) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun percent(): Optional = Optional.ofNullable(percent) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun isUnit(): Boolean = unit != null + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun isTiered(): Boolean = tiered != null + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - fun isBulk(): Boolean = bulk != null + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun isPackage(): Boolean = package_ != null + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isMatrix(): Boolean = matrix != null + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun toBuilder() = Builder().from(this) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + companion object { - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** A builder for [LicenseAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isGroupedAllocation(): Boolean = groupedAllocation != null + @JvmSynthetic + internal fun from(licenseAllocationPrice: LicenseAllocationPrice) = apply { + cadence = licenseAllocationPrice.cadence + itemId = licenseAllocationPrice.itemId + licenseAllocations = + licenseAllocationPrice.licenseAllocations.map { it.toMutableList() } + modelType = licenseAllocationPrice.modelType + name = licenseAllocationPrice.name + unitConfig = licenseAllocationPrice.unitConfig + billableMetricId = licenseAllocationPrice.billableMetricId + billedInAdvance = licenseAllocationPrice.billedInAdvance + billingCycleConfiguration = licenseAllocationPrice.billingCycleConfiguration + conversionRate = licenseAllocationPrice.conversionRate + conversionRateConfig = licenseAllocationPrice.conversionRateConfig + currency = licenseAllocationPrice.currency + dimensionalPriceConfiguration = + licenseAllocationPrice.dimensionalPriceConfiguration + externalPriceId = licenseAllocationPrice.externalPriceId + fixedPriceQuantity = licenseAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = licenseAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = licenseAllocationPrice.invoicingCycleConfiguration + licenseTypeId = licenseAllocationPrice.licenseTypeId + metadata = licenseAllocationPrice.metadata + referenceId = licenseAllocationPrice.referenceId + additionalProperties = + licenseAllocationPrice.additionalProperties.toMutableMap() + } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** The pricing model type */ + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Sets [Builder.modelType] to an arbitrary JSON value. + * + * You should usually call [Builder.modelType] with a well-typed [ModelType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun isMinimumComposite(): Boolean = minimumComposite != null + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - fun isPercent(): Boolean = percent != null + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } - fun isEventOutput(): Boolean = eventOutput != null + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - - fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = - cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - - fun asMinimumComposite(): NewPlanMinimumCompositePrice = - minimumComposite.getOrThrow("minimumComposite") - - fun asPercent(): Percent = percent.getOrThrow("percent") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - cumulativeGroupedAllocation != null -> - visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) - minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - private var validated: Boolean = false + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun validate(): Price = apply { - if (validated) { - return@apply + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } - - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } - - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } - - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) { - cumulativeGroupedAllocation.validate() - } + /** + * Returns an immutable instance of [LicenseAllocationPrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocationPrice = + LicenseAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { - minimumComposite.validate() - } + private var validated: Boolean = false - override fun visitPercent(percent: Percent) { - percent.validate() - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseAllocationPrice = apply { + if (validated) { + return@apply + } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } - } - ) + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + modelType().validate() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() validated = true } @@ -2673,867 +3473,769 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + companion object { - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + @JvmField val ANNUAL = of("annual") - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + @JvmField val SEMI_ANNUAL = of("semi_annual") - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + @JvmField val MONTHLY = of("monthly") - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JvmField val QUARTERLY = of("quarterly") - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + @JvmField val ONE_TIME = of("one_time") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + @JvmField val CUSTOM = of("custom") - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + private var validated: Boolean = false - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + known() + validated = true + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + return other is Cadence && value == other.value + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + override fun hashCode() = value.hashCode() - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + override fun toString() = value.toString() + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = cumulativeGroupedAllocation.validity() + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") - override fun visitPercent(percent: Percent) = percent.validity() + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && - minimumComposite == other.minimumComposite && - percent == other.percent && - eventOutput == other.eventOutput - } - - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - cumulativeGroupedAllocation, - minimumComposite, - percent, - eventOutput, - ) - - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - companion object { + fun toBuilder() = Builder().from(this) - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + companion object { - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { - @JvmStatic - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = licenseAllocation.additionalProperties.toMutableMap() + } - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) - @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } - @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmStatic - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + private var validated: Boolean = false - @JvmStatic - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + amount() + currency() + writeOffOverage() + validated = true + } - @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - @JvmStatic - fun ofCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + /** The pricing model type */ + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + companion object { - fun visitUnit(unit: NewPlanUnitPrice): T + @JvmField val UNIT = of("unit") - fun visitTiered(tiered: NewPlanTieredPrice): T + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } - fun visitBulk(bulk: NewPlanBulkPrice): T + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT + } - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + /** + * 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, + } - fun visitPackage(package_: NewPlanPackagePrice): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT -> Value.UNIT + else -> Value._UNKNOWN + } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT -> Known.UNIT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + private var validated: Boolean = false - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ModelType = apply { + if (validated) { + return@apply + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + known() + validated = true + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + return other is ModelType && value == other.value + } - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + override fun hashCode() = value.hashCode() - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + override fun toString() = value.toString() + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + fun toBuilder() = Builder().from(this) - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + companion object { - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + private var additionalProperties: MutableMap = mutableMapOf() - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitPercent(percent: Percent): T + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun visitEventOutput(eventOutput: EventOutput): T + private var validated: Boolean = false /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException in the default implementation. + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - internal class Deserializer : BaseDeserializer(Price::class) { + validated = true + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) - } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) - } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - return Price(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties } - } - internal class Serializer : BaseSerializer(Price::class) { + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.cumulativeGroupedAllocation != null -> - generator.writeObject(value.cumulativeGroupedAllocation) - value.minimumComposite != null -> - generator.writeObject(value.minimumComposite) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - class BulkWithFilters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val bulkWithFiltersConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bulkWithFiltersConfig, + return other is LicenseAllocationPrice && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3545,2162 +4247,1603 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, - mutableMapOf(), + additionalProperties, ) + } - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + override fun hashCode(): Int = hashCode - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + override fun toString() = + "LicenseAllocationPrice{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { - /** - * The pricing model type - * - * Expected to always return the following: - * ```java - * JsonValue.from("bulk_with_filters") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun unit(): Optional = Optional.ofNullable(unit) - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + fun tiered(): Optional = Optional.ofNullable(tiered) - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + fun bulk(): Optional = Optional.ofNullable(bulk) - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + fun package_(): Optional = Optional.ofNullable(package_) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + fun matrix(): Optional = Optional.ofNullable(matrix) - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun percent(): Optional = Optional.ofNullable(percent) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) - fun toBuilder() = Builder().from(this) + fun isUnit(): Boolean = unit != null - companion object { + fun isTiered(): Boolean = tiered != null - /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. - * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun isBulk(): Boolean = bulk != null - /** A builder for [BulkWithFilters]. */ - class Builder internal constructor() { + fun isBulkWithFilters(): Boolean = bulkWithFilters != null - private var bulkWithFiltersConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun isPackage(): Boolean = package_ != null - @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() - } + fun isMatrix(): Boolean = matrix != null - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + fun isTieredPackage(): Boolean = tieredPackage != null - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun isGroupedTiered(): Boolean = groupedTiered != null - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - /** - * 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("bulk_with_filters") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun isUnitWithPercent(): Boolean = unitWithPercent != null - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + fun isTieredWithProration(): Boolean = tieredWithProration != null - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + fun isUnitWithProration(): Boolean = unitWithProration != null - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + fun isGroupedAllocation(): Boolean = groupedAllocation != null - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + fun isBulkWithProration(): Boolean = bulkWithProration != null - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + fun isMeteredAllowance(): Boolean = meteredAllowance != null - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + fun isMinimumComposite(): Boolean = minimumComposite != null - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + fun isPercent(): Boolean = percent != null - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + fun isEventOutput(): Boolean = eventOutput != null - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") - /** - * Returns an immutable instance of [BulkWithFilters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewPlanUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { - if (validated) { - return@apply - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Price = apply { + if (validated) { + return@apply + } - bulkWithFiltersConfig().validate() - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } - @JsonCreator - private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } - /** - * Bulk tiers for rating based on total usage volume - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } - fun toBuilder() = Builder().from(this) + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } - companion object { + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } - /** A builder for [BulkWithFiltersConfig]. */ - class Builder internal constructor() { + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } - private var filters: JsonField>? = null - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } - @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() } - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() } - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() } - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() } - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() } - /** - * Returns an immutable instance of [BulkWithFiltersConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } - private var validated: Boolean = false + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } - fun validate(): BulkWithFiltersConfig = apply { - if (validated) { - return@apply + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() } - filters().forEach { it.validate() } - tiers().forEach { it.validate() } - validated = true - } + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + override fun visitPercent(percent: Percent) { + percent.validate() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() - fun toBuilder() = Builder().from(this) + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() - companion object { + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() - /** A builder for [Filter]. */ - class Builder internal constructor() { + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() - @JvmSynthetic - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() - private var validated: Boolean = false + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() - fun validate(): Filter = apply { - if (validated) { - return@apply - } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() - propertyKey() - propertyValue() - validated = true - } + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (propertyKey.asKnown().isPresent) 1 else 0) + - (if (propertyValue.asKnown().isPresent) 1 else 0) + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() - override fun hashCode(): Int = hashCode + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + override fun visitPercent(percent: Percent) = percent.validity() - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + matrixWithThresholdDiscounts, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, + minimumComposite, + percent, + eventOutput, + ) - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - fun toBuilder() = Builder().from(this) + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - companion object { + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) - /** A builder for [Tier]. */ - class Builder internal constructor() { + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) - private var validated: Boolean = false + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) - fun validate(): Tier = apply { - if (validated) { - return@apply - } + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - unitAmount() - tierLowerBound() - validated = true - } + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties - } + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - override fun hashCode(): Int = hashCode + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) - override fun hashCode(): Int = hashCode + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { - companion object { + fun visitUnit(unit: NewPlanUnitPrice): T - @JvmField val ANNUAL = of("annual") + fun visitTiered(tiered: NewPlanTieredPrice): T - @JvmField val SEMI_ANNUAL = of("semi_annual") + fun visitBulk(bulk: NewPlanBulkPrice): T - @JvmField val MONTHLY = of("monthly") + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T - @JvmField val QUARTERLY = of("quarterly") + fun visitPackage(package_: NewPlanPackagePrice): T - @JvmField val ONE_TIME = of("one_time") + fun visitMatrix(matrix: NewPlanMatrixPrice): T - @JvmField val CUSTOM = of("custom") + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T - private var validated: Boolean = false + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T - known() - validated = true - } + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - return other is Cadence && value == other.value - } + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T - override fun hashCode() = value.hashCode() + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T - override fun toString() = value.toString() - } + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T - fun toBuilder() = Builder().from(this) + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T - companion object { + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T - private var additionalProperties: MutableMap = - mutableMapOf() + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun visitPercent(percent: Percent): T - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun visitEventOutput(eventOutput: EventOutput): T - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + internal class Deserializer : BaseDeserializer(Price::class) { - private var validated: Boolean = false + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() - fun validate(): Metadata = apply { - if (validated) { - return@apply + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - bulkWithFiltersConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - class TieredWithProration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val tieredWithProrationConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + /** * The id of the item the price will be associated with. * @@ -5715,7 +5858,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5732,16 +5875,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -5846,6 +5979,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5865,6 +6006,17 @@ private constructor( */ fun referenceId(): Optional = referenceId.getOptional("reference_id") + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + /** * Returns the raw JSON value of [cadence]. * @@ -5891,17 +6043,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -6015,6 +6156,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6050,29 +6201,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```java + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -6090,45 +6239,60 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } @@ -6150,7 +6314,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6170,22 +6334,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6534,6 +6682,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6598,27 +6767,27 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6630,6 +6799,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -6638,20 +6808,30 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -6663,6 +6843,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -6684,13 +6865,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -6702,186 +6881,40 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val filters: JsonField>, private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), @JsonProperty("tiers") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -6889,6 +6922,16 @@ private constructor( */ fun tiers(): List = tiers.getRequired("tiers") + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + /** * Returns the raw JSON value of [tiers]. * @@ -6915,35 +6958,61 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```java + * .filters() * .tiers() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { + private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -6993,19 +7062,21 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -7013,11 +7084,22 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } + filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -7038,55 +7120,279 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single tiered with proration tier */ - class Tier + /** Configuration for a single property filter */ + class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, + private val propertyKey: JsonField, + private val propertyValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) /** - * Inclusive tier starting value + * Event property key to filter on * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + fun propertyKey(): String = propertyKey.getRequired("property_key") /** - * Amount per unit + * Event property value to match * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun propertyValue(): String = propertyValue.getRequired("property_value") /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns the raw JSON value of [propertyKey]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has * an unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("property_value") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") /** * Returns the raw JSON value of [unitAmount]. @@ -7098,6 +7404,16 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -7117,7 +7433,6 @@ private constructor( * * The following fields are required: * ```java - * .tierLowerBound() * .unitAmount() * ``` */ @@ -7127,46 +7442,53 @@ private constructor( /** A builder for [Tier]. */ class Builder internal constructor() { - private var tierLowerBound: JsonField? = null private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.unitAmount] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.tierLowerBound] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound } fun additionalProperties(additionalProperties: Map) = @@ -7199,7 +7521,6 @@ private constructor( * * The following fields are required: * ```java - * .tierLowerBound() * .unitAmount() * ``` * @@ -7207,21 +7528,31 @@ private constructor( */ fun build(): Tier = Tier( - checkRequired("tierLowerBound", tierLowerBound), checkRequired("unitAmount", unitAmount), + tierLowerBound, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply } - tierLowerBound() unitAmount() + tierLowerBound() validated = true } @@ -7241,8 +7572,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -7250,19 +7581,19 @@ private constructor( } return other is Tier && - tierLowerBound == other.tierLowerBound && unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -7270,120 +7601,302 @@ private constructor( return true } - return other is TieredWithProrationConfig && + return other is BulkWithFiltersConfig && + filters == other.filters && tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + private constructor(private val value: JsonField) : Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @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() - } + @JvmField val ANNUAL = of("annual") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val MONTHLY = of("monthly") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JvmField val QUARTERLY = of("quarterly") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val ONE_TIME = of("one_time") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val CUSTOM = of("custom") - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * Used for best match union deserialization. + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties } @@ -7399,12 +7912,12 @@ private constructor( return true } - return other is TieredWithProration && + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -7416,6 +7929,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -7423,11 +7937,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + bulkWithFiltersConfig, cadence, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7439,6 +7953,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -7448,16 +7963,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class MatrixWithThresholdDiscounts @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -7472,6 +7987,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -7482,14 +7998,14 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -7532,6 +8048,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7540,8 +8059,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, billableMetricId, @@ -7555,6 +8074,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -7570,32 +8090,32 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for matrix_with_threshold_discounts pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7716,6 +8236,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7745,17 +8273,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -7764,6 +8281,18 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig + /** * Returns the raw JSON value of [name]. * @@ -7885,6 +8414,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7921,29 +8460,29 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [MatrixWithThresholdDiscounts]. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [MatrixWithThresholdDiscounts]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + JsonValue.from("matrix_with_threshold_discounts") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7962,37 +8501,39 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = matrixWithThresholdDiscounts.cadence + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + currency = matrixWithThresholdDiscounts.currency dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata + referenceId = matrixWithThresholdDiscounts.referenceId additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -8007,29 +8548,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -8042,13 +8560,36 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -8416,6 +8957,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -8480,28 +9042,28 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( checkRequired("cadence", cadence), + checkRequired("itemId", itemId), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, ), - checkRequired("itemId", itemId), modelType, checkRequired("name", name), billableMetricId, @@ -8515,6 +9077,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -8523,16 +9086,26 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() + matrixWithThresholdDiscountsConfig().validate() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -8548,6 +9121,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -8570,10 +9144,11 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -8587,6 +9162,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -8710,6 +9286,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -8749,108 +9335,140 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Unit price used for usage that does not match any defined matrix cell. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The maximum amount to charge each group + * First matrix dimension key. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") /** - * The minimum amount to charge each group, regardless of usage + * Per-cell unit prices. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") /** - * The base price charged per group + * Optional second matrix dimension key. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") /** - * Returns the raw JSON value of [groupingKey]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [firstDimension]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [firstDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("first_dimension") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _firstDimension(): JsonField = firstDimension /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("matrix_values") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _matrixValues(): JsonField> = matrixValues /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [secondDimension]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [secondDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("second_dimension") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -8868,246 +9486,166 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [MatrixWithThresholdDiscountsConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties + matrixWithThresholdDiscountsConfig.additionalProperties .toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Unit price used for usage that does not match any defined matrix cell. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.defaultUnitAmount] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.firstDimension] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed + * You should usually call [Builder.firstDimension] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` + * Sets [Builder.secondDimension] to an arbitrary JSON value. * - * @throws IllegalStateException if any required field is unset. + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply - } - - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } } fun additionalProperties(additionalProperties: Map) = @@ -9133,20 +9671,56 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { if (validated) { return@apply } + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } validated = true } @@ -9166,3348 +9740,2761 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + mutableMapOf(), + ) - return other is Metadata && - additionalProperties == other.additionalProperties - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - override fun hashCode(): Int = hashCode + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + fun toBuilder() = Builder().from(this) - class CumulativeGroupedAllocation - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + companion object { - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - cumulativeGroupedAllocationConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { - /** - * Configuration for cumulative_grouped_allocation pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } - /** - * The pricing model type - * - * Expected to always return the following: - * ```java - * JsonValue.from("cumulative_grouped_allocation") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + private var validated: Boolean = false - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. - * - * The following fields are required: - * ```java - * .cadence() - * .cumulativeGroupedAllocationConfig() - * .itemId() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** A builder for [CumulativeGroupedAllocation]. */ - class Builder internal constructor() { + fun toBuilder() = Builder().from(this) - private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + companion object { - @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) - /** - * 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("cumulative_grouped_allocation") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + fun description(description: String?) = + description(JsonField.ofNullable(description)) - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + private var validated: Boolean = false - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + override fun hashCode(): Int = hashCode - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, ) + } - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + companion object { - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + private var validated: Boolean = false /** - * Sets [Builder.referenceId] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): Metadata = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .cadence() - * .cumulativeGroupedAllocationConfig() - * .itemId() - * .name() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( - checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): CumulativeGroupedAllocation = apply { - if (validated) { - return@apply + return other is Metadata && + additionalProperties == other.additionalProperties } - cadence().validate() - cumulativeGroupedAllocationConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_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) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - companion object { + override fun hashCode(): Int = hashCode - @JvmField val ANNUAL = of("annual") + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - @JvmField val SEMI_ANNUAL = of("semi_annual") + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JvmField val MONTHLY = of("monthly") + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - @JvmField val QUARTERLY = of("quarterly") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - @JvmField val ONE_TIME = of("one_time") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JvmField val CUSTOM = of("custom") + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - private var validated: Boolean = false + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - known() - validated = true - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - return other is Cadence && value == other.value - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - override fun hashCode() = value.hashCode() + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - override fun toString() = value.toString() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, - private val groupingKey: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - @JsonCreator - private constructor( - @JsonProperty("cumulative_allocation") - @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") - @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - mutableMapOf(), - ) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * The overall allocation across all groups - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * The allocation per individual group + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** - * The event property used to group usage before applying allocations + * Sets [Builder.cadence] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** - * The amount to charge for each unit outside of the allocation + * Sets [Builder.itemId] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sets the field to an arbitrary JSON value. * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field - * has an unexpected type. + * 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. */ - @JsonProperty("cumulative_allocation") - @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** - * Returns the raw JSON value of [groupAllocation]. + * Sets [Builder.name] to an arbitrary JSON value. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("group_allocation") - @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) /** - * Returns the raw JSON value of [groupingKey]. + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * The id of the billable metric for the price. Only needed if the price is + * usage-based. */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - companion object { + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. - * - * The following fields are required: - * ```java - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - /** A builder for [CumulativeGroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null - private var groupingKey: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount - additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. - * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - /** The event property used to group usage before applying allocations */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The amount to charge for each unit outside of the allocation */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), - checkRequired("groupingKey", groupingKey), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - private var validated: Boolean = false + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun validate(): CumulativeGroupedAllocationConfig = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - cumulativeAllocation() - groupAllocation() - groupingKey() - unitAmount() - validated = true - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - @JvmSynthetic - internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && - groupingKey == other.groupingKey && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - private val hashCode: Int by lazy { - Objects.hash( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - additionalProperties, - ) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - override fun hashCode(): Int = hashCode - - override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId } - private var validated: Boolean = false + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - validated = true - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.referenceId] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - return other is Metadata && - additionalProperties == other.additionalProperties + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - return other is CumulativeGroupedAllocation && - cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) } - private val hashCode: Int by lazy { - Objects.hash( - cadence, - cumulativeGroupedAllocationConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - class Percent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val percentConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + private var validated: Boolean = false /** - * The pricing model type + * Validates that the types of all values in this object match their expected types + * recursively. * - * Expected to always return the following: - * ```java - * JsonValue.from("percent") - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Used for best match union deserialization. */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + companion object { - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + @JvmField val ANNUAL = of("annual") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + @JvmField val SEMI_ANNUAL = of("semi_annual") - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + @JvmField val MONTHLY = of("monthly") - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + @JvmField val QUARTERLY = of("quarterly") - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + @JvmField val ONE_TIME = of("one_time") - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + @JvmField val CUSTOM = of("custom") - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + private var validated: Boolean = false - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + known() + validated = true + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```java - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` + * Used for best match union deserialization. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Percent]. */ - class Builder internal constructor() { + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") - private var name: JsonField? = null - private var percentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmSynthetic - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() + return other is Cadence && value == other.value } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + override fun hashCode() = value.hashCode() - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + override fun toString() = value.toString() + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * Sets [Builder.itemId] to an arbitrary JSON value. + * Tiers for rating based on total usage quantities into the specified tier with + * proration * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun tiers(): List = tiers.getRequired("tiers") /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("percent") - * ``` + * Returns the raw JSON value of [tiers]. * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + private var validated: Boolean = false /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + tiers().forEach { it.validate() } + validated = true + } - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + fun toBuilder() = Builder().from(this) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + companion object { - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + private var validated: Boolean = false - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + tierLowerBound() + unitAmount() + validated = true + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * Returns an immutable instance of [Percent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Percent = - Percent( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - checkRequired("percentConfig", percentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } - private var validated: Boolean = false + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun validate(): Percent = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("percent")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - percentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for percent pricing */ - class PercentConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val percent: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("percent") - @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) - - /** - * What percent of the component subtotals to charge - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun percent(): Double = percent.getRequired("percent") - - /** - * Returns the raw JSON value of [percent]. - * - * Unlike [percent], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent") - @ExcludeMissing - fun _percent(): JsonField = percent - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [PercentConfig]. - * - * The following fields are required: - * ```java - * .percent() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentConfig]. */ - class Builder internal constructor() { - - private var percent: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() - } - - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) - - /** - * Sets [Builder.percent] to an arbitrary JSON value. - * - * You should usually call [Builder.percent] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun percent(percent: JsonField) = apply { this.percent = percent } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PercentConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .percent() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PercentConfig = apply { - if (validated) { - return@apply - } - - percent() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PercentConfig && - percent == other.percent && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + 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]. */ @@ -12553,6 +12540,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -12602,12 +12599,12 @@ private constructor( return true } - return other is Percent && + return other is TieredWithProration && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12619,6 +12616,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12630,7 +12628,7 @@ private constructor( itemId, modelType, name, - percentConfig, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12642,6 +12640,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12651,14 +12650,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -12674,6 +12674,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12684,9 +12685,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -12732,6 +12735,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12740,7 +12746,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -12755,6 +12761,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12770,14 +12777,16 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for event_output pricing + * Configuration for grouped_with_min_max_thresholds pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) /** * The id of the item the price will be associated with. @@ -12793,7 +12802,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12914,6 +12923,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12944,14 +12961,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [eventOutputConfig]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("event_output_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig /** * Returns the raw JSON value of [itemId]. @@ -13082,6 +13100,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -13117,12 +13145,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() * ``` @@ -13130,13 +13159,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -13155,58 +13187,74 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } /** The id of the item the price will be associated with. */ @@ -13227,7 +13275,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13595,6 +13643,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13659,24 +13728,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -13691,6 +13763,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13699,16 +13772,26 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -13724,6 +13807,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13746,9 +13830,11 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -13761,6 +13847,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -13884,6 +13971,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -13923,87 +14020,108 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") - @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. + * The maximum amount to charge each group * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun defaultUnitRate(): Optional = - defaultUnitRate.getOptional("default_unit_rate") + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. + * The minimum amount to charge each group, regardless of usage * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") /** - * Returns the raw JSON value of [unitRatingKey]. + * The base price charged per group * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_rating_key") + @JsonProperty("grouping_key") @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [defaultUnitRate]. + * Returns the raw JSON value of [maximumCharge]. * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("default_unit_rate") + @JsonProperty("maximum_charge") @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun _maximumCharge(): JsonField = maximumCharge /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [minimumCharge]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("minimum_charge") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -14021,97 +14139,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```java - * .unitRatingKey() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Alias for calling [Builder.defaultUnitRate] with - * `defaultUnitRate.orElse(null)`. - */ - fun defaultUnitRate(defaultUnitRate: Optional) = - defaultUnitRate(defaultUnitRate.getOrNull()) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * You should usually call [Builder.defaultUnitRate] with a well-typed + * You should usually call [Builder.maximumCharge] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) /** - * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: Optional) = - groupingKey(groupingKey.getOrNull()) + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.perUnitRate] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.perUnitRate] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate } fun additionalProperties(additionalProperties: Map) = @@ -14137,36 +14258,51 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .unitRatingKey() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -14186,27 +14322,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (unitRatingKey.asKnown().isPresent) 1 else 0) + - (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && + return other is GroupedWithMinMaxThresholdsConfig && groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - unitRatingKey, - defaultUnitRate, groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, additionalProperties, ) } @@ -14214,7 +14353,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -14284,6 +14423,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -14333,9 +14482,10 @@ private constructor( return true } - return other is EventOutput && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -14350,6 +14500,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -14358,7 +14509,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -14373,6 +14524,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -14382,4659 +14534,22891 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - override fun hashCode(): Int = hashCode + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun toBuilder() = Builder().from(this) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - companion object { + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - @JvmSynthetic - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var validated: Boolean = false + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (adjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + fun toBuilder() = Builder().from(this) - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + companion object { - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } - fun toBuilder() = Builder().from(this) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - companion object { + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - @JvmSynthetic - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * 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("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - private var validated: Boolean = false + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - priceId() - planPhaseOrder() - validated = true - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (priceId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) - - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } - - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) - - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - private var validated: Boolean = false + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + private var validated: Boolean = false - fun minimum(): Optional = Optional.ofNullable(minimum) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } - fun maximum(): Optional = Optional.ofNullable(maximum) + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("cumulative_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) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - fun isAmountDiscount(): Boolean = amountDiscount != null + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun isMinimum(): Boolean = minimum != null + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the 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 isMaximum(): Boolean = maximum != null + companion object { - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + @JvmField val ANNUAL = of("annual") - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + @JvmField val MONTHLY = of("monthly") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JvmField val QUARTERLY = of("quarterly") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + @JvmField val ONE_TIME = of("one_time") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val CUSTOM = of("custom") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - private var validated: Boolean = false + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + private var validated: Boolean = false - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = 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 = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + known() + validated = true + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun unknown(json: JsonValue?) = 0 + return other is Cadence && value == other.value } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + override fun hashCode() = value.hashCode() - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + override fun toString() = value.toString() + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitMinimum(minimum: NewMinimum): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitMaximum(maximum: NewMaximum): T + fun toBuilder() = Builder().from(this) - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + companion object { - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() } - } - return Adjustment(_json = json) - } - } + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) - internal class Serializer : BaseSerializer(Adjustment::class) { + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun hashCode(): Int = hashCode + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): Optional = - allocationPrice.getOptional("allocation_price") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + private var validated: Boolean = false - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun toBuilder() = Builder().from(this) + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun hashCode(): Int = hashCode - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + companion object { - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + validated = true + } - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + class DailyCreditAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val dailyCreditAllowanceConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + dailyCreditAllowanceConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + dailyCreditAllowanceConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** + * Configuration for daily_credit_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. - */ - fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = - price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) - - /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ - fun price(minimumComposite: NewPlanMinimumCompositePrice) = - price(Price.ofMinimumComposite(minimumComposite)) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - private var validated: Boolean = false + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - planPhaseOrder() - price().ifPresent { it.validate() } - validated = true - } + /** + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. + * + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun tiered(): Optional = Optional.ofNullable(tiered) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun bulk(): Optional = Optional.ofNullable(bulk) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun package_(): Optional = Optional.ofNullable(package_) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun matrix(): Optional = Optional.ofNullable(matrix) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + fun toBuilder() = Builder().from(this) - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + companion object { - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun groupedWithProratedMinimum(): Optional = - Optional.ofNullable(groupedWithProratedMinimum) + /** A builder for [DailyCreditAllowance]. */ + class Builder internal constructor() { - fun groupedWithMeteredMinimum(): Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + private var cadence: JsonField? = null + private var dailyCreditAllowanceConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun groupedWithMinMaxThresholds(): Optional = - Optional.ofNullable(groupedWithMinMaxThresholds) + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + currency = dailyCreditAllowance.currency + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + referenceId = dailyCreditAllowance.referenceId + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + /** + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun cumulativeGroupedAllocation(): Optional = - Optional.ofNullable(cumulativeGroupedAllocation) + /** + * 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("daily_credit_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun minimumComposite(): Optional = - Optional.ofNullable(minimumComposite) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun percent(): Optional = Optional.ofNullable(percent) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun isUnit(): Boolean = unit != null + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - fun isTiered(): Boolean = tiered != null + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun isBulk(): Boolean = bulk != null + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun isPackage(): Boolean = package_ != null + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun isMatrix(): Boolean = matrix != null + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun isMinimumComposite(): Boolean = minimumComposite != null + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun isPercent(): Boolean = percent != null + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun isEventOutput(): Boolean = eventOutput != null + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Returns an immutable instance of [DailyCreditAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowance = + DailyCreditAllowance( + checkRequired("cadence", cadence), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + private var validated: Boolean = false - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { + if (validated) { + return@apply + } - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + cadence().validate() + dailyCreditAllowanceConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("daily_credit_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - - fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = - cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asMinimumComposite(): NewPlanMinimumCompositePrice = - minimumComposite.getOrThrow("minimumComposite") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - fun asPercent(): Percent = percent.getOrThrow("percent") + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the 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 _json(): Optional = Optional.ofNullable(_json) + companion object { - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - cumulativeGroupedAllocation != null -> - visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) - minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } + @JvmField val ANNUAL = of("annual") - private var validated: Boolean = false + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun validate(): Price = apply { - if (validated) { - return@apply - } + @JvmField val MONTHLY = of("monthly") - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + @JvmField val QUARTERLY = of("quarterly") - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + @JvmField val ONE_TIME = of("one_time") - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + @JvmField val CUSTOM = of("custom") - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + private var validated: Boolean = false - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + known() + validated = true + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + return other is Cadence && value == other.value + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + override fun hashCode() = value.hashCode() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + override fun toString() = value.toString() + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + @JsonCreator + private constructor( + @JsonProperty("daily_allowance") + @ExcludeMissing + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") + @ExcludeMissing + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** + * Credits granted per day. Lose-it-or-use-it; does not roll over. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + /** + * One or two event property values to evaluate matrix groups by + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensions(): List = dimensions.getRequired("dimensions") - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** + * Per-dimension credit rates + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("daily_allowance") + @ExcludeMissing + fun _dailyAllowance(): JsonField = dailyAllowance - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) { - cumulativeGroupedAllocation.validate() - } + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { - minimumComposite.validate() - } + /** + * Returns the raw JSON value of [eventDayProperty]. + * + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_day_property") + @ExcludeMissing + fun _eventDayProperty(): JsonField = eventDayProperty - override fun visitPercent(percent: Percent) { - percent.validate() - } + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + fun toBuilder() = Builder().from(this) - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + companion object { - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowanceConfig]. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + /** A builder for [DailyCreditAllowanceConfig]. */ + class Builder internal constructor() { - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + @JvmSynthetic + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + /** + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() - - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * Sets [Builder.dimensions] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + private var validated: Boolean = false - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = cumulativeGroupedAllocation.validity() + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitPercent(percent: Percent) = percent.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && - minimumComposite == other.minimumComposite && - percent == other.percent && - eventOutput == other.eventOutput - } + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - cumulativeGroupedAllocation, - minimumComposite, - percent, - eventOutput, - ) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + fun toBuilder() = Builder().from(this) - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + companion object { - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } - @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) - @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JvmStatic - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + private var validated: Boolean = false - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + dimensionValues() + unitAmount() + validated = true + } - @JvmStatic - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) - @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - @JvmStatic - fun ofCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties + } - @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + private val hashCode: Int by lazy { + Objects.hash( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + additionalProperties, + ) + } - @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + override fun hashCode(): Int = hashCode - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + override fun toString() = + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" + } - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitTiered(tiered: NewPlanTieredPrice): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitBulk(bulk: NewPlanBulkPrice): T + fun toBuilder() = Builder().from(this) - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + companion object { - fun visitPackage(package_: NewPlanPackagePrice): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + private var validated: Boolean = false - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + validated = true + } - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + override fun hashCode(): Int = hashCode - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + return other is DailyCreditAllowance && + cadence == other.cadence && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + private val hashCode: Int by lazy { + Objects.hash( + cadence, + dailyCreditAllowanceConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ): T + override fun hashCode(): Int = hashCode - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + override fun toString() = + "DailyCreditAllowance{cadence=$cadence, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - fun visitPercent(percent: Percent): T + class MeteredAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun visitEventOutput(eventOutput: EventOutput): T + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + meteredAllowanceConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) /** - * Maps an unknown variant of [Price] to a value of type [T]. + * The cadence to bill for this price on. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. * - * @throws OrbInvalidDataException in the default implementation. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun itemId(): String = itemId.getRequired("item_id") - internal class Deserializer : BaseDeserializer(Price::class) { + /** + * Configuration for metered_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("metered_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .meteredAllowanceConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MeteredAllowance]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + currency = meteredAllowance.currency + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + referenceId = meteredAllowance.referenceId + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + + /** + * 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("metered_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MeteredAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .meteredAllowanceConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MeteredAllowance = + MeteredAllowance( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + meteredAllowanceConfig().validate() + _modelType().let { + if (it != JsonValue.from("metered_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowance_grouping_value") + @ExcludeMissing + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") + @ExcludeMissing + consumptionGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), + ) : this( + allowanceGroupingValue, + consumptionGroupingValue, + groupingKey, + unitAmount, + allowanceDisplayName, + consumptionDisplayName, + mutableMapOf(), + ) + + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") + + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") + + /** + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Per-unit price applied to gross consumption and to the allowance credit. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_grouping_value") + @ExcludeMissing + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue + + /** + * Returns the raw JSON value of [consumptionGroupingValue]. + * + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumption_grouping_value") + @ExcludeMissing + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MeteredAllowanceConfig]. + * + * The following fields are required: + * ```java + * .allowanceGroupingValue() + * .consumptionGroupingValue() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MeteredAllowanceConfig]. */ + class Builder internal constructor() { + + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName + additionalProperties = + meteredAllowanceConfig.additionalProperties.toMutableMap() + } + + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) + + /** + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } + + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) + + /** + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } + + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MeteredAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowanceGroupingValue() + * .consumptionGroupingValue() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { + if (validated) { + return@apply + } + + allowanceGroupingValue() + consumptionGroupingValue() + groupingKey() + unitAmount() + allowanceDisplayName() + consumptionDisplayName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowanceGroupingValue, + consumptionGroupingValue, + groupingKey, + unitAmount, + allowanceDisplayName, + consumptionDisplayName, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MeteredAllowance && + cadence == other.cadence && + itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + meteredAllowanceConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MeteredAllowance{cadence=$cadence, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (adjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(maximum) + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): Optional = + allocationPrice.getOptional("allocation_price") + + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Optional = price.getOptional("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + licenseAllocationPrice = replacePrice.licenseAllocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ + fun price(minimumComposite: NewPlanMinimumCompositePrice) = + price(Price.ofMinimumComposite(minimumComposite)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } + planPhaseOrder() + price().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + /** The license allocation price to add to the plan. */ + class LicenseAllocationPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonField, + private val name: JsonField, + private val unitConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a per-license + * credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [modelType]. + * + * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocationPrice: LicenseAllocationPrice) = apply { + cadence = licenseAllocationPrice.cadence + itemId = licenseAllocationPrice.itemId + licenseAllocations = + licenseAllocationPrice.licenseAllocations.map { it.toMutableList() } + modelType = licenseAllocationPrice.modelType + name = licenseAllocationPrice.name + unitConfig = licenseAllocationPrice.unitConfig + billableMetricId = licenseAllocationPrice.billableMetricId + billedInAdvance = licenseAllocationPrice.billedInAdvance + billingCycleConfiguration = licenseAllocationPrice.billingCycleConfiguration + conversionRate = licenseAllocationPrice.conversionRate + conversionRateConfig = licenseAllocationPrice.conversionRateConfig + currency = licenseAllocationPrice.currency + dimensionalPriceConfiguration = + licenseAllocationPrice.dimensionalPriceConfiguration + externalPriceId = licenseAllocationPrice.externalPriceId + fixedPriceQuantity = licenseAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = licenseAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = licenseAllocationPrice.invoicingCycleConfiguration + licenseTypeId = licenseAllocationPrice.licenseTypeId + metadata = licenseAllocationPrice.metadata + referenceId = licenseAllocationPrice.referenceId + additionalProperties = + licenseAllocationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** The pricing model type */ + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + /** + * Sets [Builder.modelType] to an arbitrary JSON value. + * + * You should usually call [Builder.modelType] with a well-typed [ModelType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocationPrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocationPrice = + LicenseAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseAllocationPrice = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + modelType().validate() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** The pricing model type */ + 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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ModelType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocationPrice && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocationPrice{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewPlanUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + matrixWithThresholdDiscounts, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithThresholdDiscounts + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Configuration for matrix_with_threshold_discounts pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_threshold_discounts") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscounts]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscounts]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null + private var modelType: JsonValue = + JsonValue.from("matrix_with_threshold_discounts") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = + apply { + cadence = matrixWithThresholdDiscounts.cadence + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance + billingCycleConfiguration = + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + currency = matrixWithThresholdDiscounts.currency + dimensionalPriceConfiguration = + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata + referenceId = matrixWithThresholdDiscounts.referenceId + additionalProperties = + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + + /** + * 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_with_threshold_discounts") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired( + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + matrixWithThresholdDiscountsConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) + + /** + * Unit price used for usage that does not match any defined matrix cell. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** + * First matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Per-cell unit prices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Optional second matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscountsConfig]. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ + class Builder internal constructor() { + + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = apply { + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } + additionalProperties = + matrixWithThresholdDiscountsConfig.additionalProperties + .toMutableMap() + } + + /** + * Unit price used for usage that does not match any defined matrix cell. + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "cumulative_grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) - } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) - } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - return Price(_json = json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) } - } - internal class Serializer : BaseSerializer(Price::class) { + private var validated: Boolean = false - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.cumulativeGroupedAllocation != null -> - generator.writeObject(value.cumulativeGroupedAllocation) - value.minimumComposite != null -> - generator.writeObject(value.minimumComposite) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true } - } - class BulkWithFilters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val bulkWithFiltersConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator - private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bulkWithFiltersConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + @JvmField val SEMI_ANNUAL = of("semi_annual") - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + @JvmField val MONTHLY = of("monthly") - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JvmField val QUARTERLY = of("quarterly") - /** - * The pricing model type - * - * Expected to always return the following: - * ```java - * JsonValue.from("bulk_with_filters") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + @JvmField val ONE_TIME = of("one_time") - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + @JvmField val CUSTOM = of("custom") - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + private var validated: Boolean = false - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + known() + validated = true + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + return other is Cadence && value == other.value + } - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + companion object { - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithFilters]. */ - class Builder internal constructor() { - - private var bulkWithFiltersConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + tiers().forEach { it.validate() } + validated = true } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * 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("bulk_with_filters") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + companion object { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + companion object { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + private var additionalProperties: MutableMap = + mutableMapOf() - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + private var validated: Boolean = false /** - * Alias for [Builder.fixedPriceQuantity]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + validated = true + } - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + override fun hashCode(): Int = hashCode - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Returns an immutable instance of [BulkWithFilters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - private var validated: Boolean = false + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun validate(): BulkWithFilters = apply { - if (validated) { - return@apply - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - bulkWithFiltersConfig().validate() - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * The configuration for the rate of the price currency to the invoicing currency. * - * Used for best match union deserialization. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JvmSynthetic - internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - @JsonCreator - private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Bulk tiers for rating based on total usage volume - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - fun toBuilder() = Builder().from(this) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - companion object { + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** A builder for [BulkWithFiltersConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var filters: JsonField>? = null - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns an immutable instance of [BulkWithFiltersConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun validate(): BulkWithFiltersConfig = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - filters().forEach { it.validate() } - tiers().forEach { it.validate() } - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * - * Used for best match union deserialization. + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` */ - @JvmSynthetic - internal fun validity(): Int = - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) + @JvmStatic fun builder() = Builder() + } - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - companion object { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** A builder for [Filter]. */ - class Builder internal constructor() { + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JvmSynthetic - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): Filter = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - propertyKey() - propertyValue() - validated = true - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (propertyKey.asKnown().isPresent) 1 else 0) + - (if (propertyValue.asKnown().isPresent) 1 else 0) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - companion object { + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** A builder for [Tier]. */ - class Builder internal constructor() { + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - private var validated: Boolean = false + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun validate(): Tier = apply { - if (validated) { - return@apply - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - unitAmount() - tierLowerBound() - validated = true - } + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) /** The cadence to bill for this price on. */ class Cadence @@ -19156,6 +37540,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -19195,6 +37589,342 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -19262,6 +37992,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -19311,9 +38051,10 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -19328,6 +38069,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -19335,8 +38077,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -19351,6 +38093,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -19360,17 +38103,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -19383,6 +38127,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -19393,6 +38138,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -19402,10 +38152,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -19442,6 +38188,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -19450,10 +38199,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -19465,6 +38214,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -19479,6 +38229,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -19493,7 +38255,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -19510,16 +38272,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -19624,6 +38376,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -19653,6 +38413,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -19669,17 +38440,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -19793,6 +38553,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -19829,28 +38599,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -19868,35 +38640,40 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -19910,6 +38687,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -19928,7 +38728,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -19948,22 +38748,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -20312,6 +39096,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -20376,27 +39181,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -20408,6 +39216,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -20416,20 +39225,30 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -20441,6 +39260,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -20463,12 +39283,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -20480,6 +39300,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -20603,6 +39424,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -20642,40 +39473,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("cumulative_allocation") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [tiers]. + * The allocation per individual group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -20693,59 +39599,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -20771,32 +39718,51 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -20816,249 +39782,38 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -21128,6 +39883,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -21177,12 +39942,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -21194,6 +39960,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -21202,10 +39969,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -21217,6 +39984,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -21226,15 +39994,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class DailyCreditAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val dailyCreditAllowanceConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -21250,6 +40017,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -21260,10 +40028,9 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = + dailyCreditAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -21310,6 +40077,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -21318,7 +40088,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -21333,6 +40103,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -21348,16 +40119,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for daily_credit_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") /** * The id of the item the price will be associated with. @@ -21373,7 +40142,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -21494,6 +40263,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -21524,15 +40301,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig /** * Returns the raw JSON value of [itemId]. @@ -21663,6 +40440,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -21699,12 +40486,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [DailyCreditAllowance]. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` @@ -21712,16 +40499,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [DailyCreditAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = + private var dailyCreditAllowanceConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -21740,38 +40525,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + currency = dailyCreditAllowance.currency + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + referenceId = dailyCreditAllowance.referenceId + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -21785,28 +40569,22 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -21826,7 +40604,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -22194,6 +40972,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -22258,27 +41057,24 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [DailyCreditAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): DailyCreditAllowance = + DailyCreditAllowance( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -22293,6 +41089,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -22301,16 +41098,26 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + dailyCreditAllowanceConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("daily_credit_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -22326,6 +41133,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -22348,10 +41156,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -22365,6 +41173,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -22488,6 +41297,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -22527,108 +41346,144 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Credits granted per day. Lose-it-or-use-it; does not roll over. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") /** - * The maximum amount to charge each group + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The minimum amount to charge each group, regardless of usage + * One or two event property values to evaluate matrix groups by * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun dimensions(): List = dimensions.getRequired("dimensions") /** - * The base price charged per group + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") /** - * Returns the raw JSON value of [groupingKey]. + * Per-dimension credit rates * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _dailyAllowance(): JsonField = dailyAllowance /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("dimensions") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _dimensions(): JsonField> = dimensions /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [eventDayProperty]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("event_day_property") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _eventDayProperty(): JsonField = eventDayProperty /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("matrix_values") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _matrixValues(): JsonField> = matrixValues @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -22646,100 +41501,583 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [DailyCreditAllowanceConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [DailyCreditAllowanceConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.defaultUnitAmount] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.dimensions] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) + + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + dimensionValues() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -22765,161 +42103,25 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply - } - - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Validates that the types of all values in this object match their expected + * types recursively. * - * Used for best match union deserialization. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - fun validate(): Metadata = apply { if (validated) { return@apply @@ -22969,10 +42171,9 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is DailyCreditAllowance && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -22987,6 +42188,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -22995,7 +42197,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -23010,6 +42212,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -23019,16 +42222,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -23043,6 +42245,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -23053,14 +42256,12 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -23103,6 +42304,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23111,8 +42315,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -23126,6 +42330,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23141,32 +42346,30 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for metered_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -23287,6 +42490,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -23316,17 +42527,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [itemId]. * @@ -23335,6 +42535,17 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + /** * Returns the raw JSON value of [name]. * @@ -23456,6 +42667,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -23491,30 +42712,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -23533,38 +42750,35 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + currency = meteredAllowance.currency + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + referenceId = meteredAllowance.referenceId + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -23578,29 +42792,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -23613,13 +42804,28 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + /** * 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("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -23987,6 +43193,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -24051,28 +43278,25 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), modelType, checkRequired("name", name), billableMetricId, @@ -24086,6 +43310,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -24094,16 +43319,26 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() itemId() + meteredAllowanceConfig().validate() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -24119,6 +43354,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -24141,11 +43377,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -24158,6 +43392,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -24281,6 +43516,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -24320,60 +43565,76 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), ) : this( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, mutableMapOf(), ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -24382,7 +43643,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -24391,24 +43652,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -24430,6 +43709,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -24446,12 +43745,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -24459,61 +43758,75 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) @@ -24528,7 +43841,9 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -24542,6 +43857,37 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -24565,41 +43911,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -24619,30 +43979,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -24650,7 +44016,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } /** @@ -24720,6 +44086,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -24769,11 +44145,10 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -24787,6 +44162,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -24795,8 +44171,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -24810,6 +44186,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -24819,7 +44196,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MeteredAllowance{cadence=$cadence, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -24842,6 +44219,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -24900,6 +44278,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -24923,6 +44304,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -25081,6 +44463,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -25249,6 +44639,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25322,6 +44722,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -25344,6 +44745,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -25762,6 +45164,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -25858,6 +45281,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -25866,6 +45290,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -25891,6 +45325,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -25928,6 +45363,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -26051,6 +45487,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -26218,6 +45664,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -26331,6 +45787,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -26397,6 +45863,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26420,6 +45887,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26429,7 +45897,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -26452,6 +45920,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26510,6 +45979,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26533,6 +46005,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -26692,6 +46165,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -26860,6 +46341,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -26933,6 +46424,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -26955,6 +46447,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -27373,6 +46866,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27469,6 +46983,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27477,6 +46992,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -27502,6 +47027,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -27539,6 +47065,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -27662,6 +47189,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -27937,6 +47474,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -28062,6 +47609,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -28128,6 +47685,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -28151,6 +47709,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -28160,7 +47719,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -28172,6 +47731,7 @@ private constructor( return other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties @@ -28181,6 +47741,7 @@ private constructor( Objects.hash( replacesPriceId, allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties, @@ -28190,7 +47751,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt index 7f3b7ebb3..559b474fd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParams.kt @@ -1101,6 +1101,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1443,6 +1452,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AddAdjustment = apply { if (validated) { return@apply @@ -1519,6 +1537,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentageDiscount != null -> @@ -1532,6 +1580,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -1764,6 +1822,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, private val additionalProperties: MutableMap, @@ -1774,11 +1833,14 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(allocationPrice, licenseAllocationPrice, planPhaseOrder, price, mutableMapOf()) /** * The allocation price to add to the plan. @@ -1789,6 +1851,15 @@ private constructor( fun allocationPrice(): Optional = allocationPrice.getOptional("allocation_price") + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + /** * The phase to add this price to. * @@ -1815,6 +1886,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -1854,6 +1935,7 @@ private constructor( class Builder internal constructor() { private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1861,6 +1943,7 @@ private constructor( @JvmSynthetic internal fun from(addPrice: AddPrice) = apply { allocationPrice = addPrice.allocationPrice + licenseAllocationPrice = addPrice.licenseAllocationPrice planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price additionalProperties = addPrice.additionalProperties.toMutableMap() @@ -1885,6 +1968,29 @@ private constructor( this.allocationPrice = allocationPrice } + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -1987,6 +2093,13 @@ private constructor( fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -2075,6 +2188,16 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: NewPlanMinimumCompositePrice) = price(Price.ofMinimumComposite(minimumComposite)) @@ -2112,6 +2235,7 @@ private constructor( fun build(): AddPrice = AddPrice( allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties.toMutableMap(), @@ -2120,12 +2244,22 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AddPrice = apply { if (validated) { return@apply } allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } planPhaseOrder() price().ifPresent { it.validate() } validated = true @@ -2148,518 +2282,1184 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price + /** The license allocation price to add to the plan. */ + class LicenseAllocationPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonField, + private val name: JsonField, + private val unitConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - fun tiered(): Optional = Optional.ofNullable(tiered) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun bulk(): Optional = Optional.ofNullable(bulk) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + /** + * License allocations to associate with this price. Each entry defines a per-license + * credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") - fun package_(): Optional = Optional.ofNullable(package_) + /** + * The pricing model type + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun modelType(): ModelType = modelType.getRequired("model_type") - fun matrix(): Optional = Optional.ofNullable(matrix) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - fun groupedWithProratedMinimum(): Optional = - Optional.ofNullable(groupedWithProratedMinimum) + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - fun groupedWithMeteredMinimum(): Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - fun groupedWithMinMaxThresholds(): Optional = - Optional.ofNullable(groupedWithMinMaxThresholds) + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + /** + * 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 - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig - fun cumulativeGroupedAllocation(): Optional = - Optional.ofNullable(cumulativeGroupedAllocation) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun minimumComposite(): Optional = - Optional.ofNullable(minimumComposite) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun percent(): Optional = Optional.ofNullable(percent) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun isUnit(): Boolean = unit != null + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun isTiered(): Boolean = tiered != null + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - fun isBulk(): Boolean = bulk != null + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun isPackage(): Boolean = package_ != null + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isMatrix(): Boolean = matrix != null + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun toBuilder() = Builder().from(this) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + companion object { - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** A builder for [LicenseAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isGroupedAllocation(): Boolean = groupedAllocation != null + @JvmSynthetic + internal fun from(licenseAllocationPrice: LicenseAllocationPrice) = apply { + cadence = licenseAllocationPrice.cadence + itemId = licenseAllocationPrice.itemId + licenseAllocations = + licenseAllocationPrice.licenseAllocations.map { it.toMutableList() } + modelType = licenseAllocationPrice.modelType + name = licenseAllocationPrice.name + unitConfig = licenseAllocationPrice.unitConfig + billableMetricId = licenseAllocationPrice.billableMetricId + billedInAdvance = licenseAllocationPrice.billedInAdvance + billingCycleConfiguration = licenseAllocationPrice.billingCycleConfiguration + conversionRate = licenseAllocationPrice.conversionRate + conversionRateConfig = licenseAllocationPrice.conversionRateConfig + currency = licenseAllocationPrice.currency + dimensionalPriceConfiguration = + licenseAllocationPrice.dimensionalPriceConfiguration + externalPriceId = licenseAllocationPrice.externalPriceId + fixedPriceQuantity = licenseAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = licenseAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = licenseAllocationPrice.invoicingCycleConfiguration + licenseTypeId = licenseAllocationPrice.licenseTypeId + metadata = licenseAllocationPrice.metadata + referenceId = licenseAllocationPrice.referenceId + additionalProperties = + licenseAllocationPrice.additionalProperties.toMutableMap() + } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** The pricing model type */ + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Sets [Builder.modelType] to an arbitrary JSON value. + * + * You should usually call [Builder.modelType] with a well-typed [ModelType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun isMinimumComposite(): Boolean = minimumComposite != null + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - fun isPercent(): Boolean = percent != null + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } - fun isEventOutput(): Boolean = eventOutput != null + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - - fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = - cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - - fun asMinimumComposite(): NewPlanMinimumCompositePrice = - minimumComposite.getOrThrow("minimumComposite") - - fun asPercent(): Percent = percent.getOrThrow("percent") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - cumulativeGroupedAllocation != null -> - visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) - minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - private var validated: Boolean = false + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun validate(): Price = apply { - if (validated) { - return@apply + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } - - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } - - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } - - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) { - cumulativeGroupedAllocation.validate() - } + /** + * Returns an immutable instance of [LicenseAllocationPrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocationPrice = + LicenseAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { - minimumComposite.validate() - } + private var validated: Boolean = false - override fun visitPercent(percent: Percent) { - percent.validate() - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseAllocationPrice = apply { + if (validated) { + return@apply + } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } - } - ) + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + modelType().validate() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() validated = true } @@ -2679,867 +3479,769 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + companion object { - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + @JvmField val ANNUAL = of("annual") - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + @JvmField val SEMI_ANNUAL = of("semi_annual") - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + @JvmField val MONTHLY = of("monthly") - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JvmField val QUARTERLY = of("quarterly") - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + @JvmField val ONE_TIME = of("one_time") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + @JvmField val CUSTOM = of("custom") - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + private var validated: Boolean = false - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + known() + validated = true + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + return other is Cadence && value == other.value + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + override fun hashCode() = value.hashCode() - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + override fun toString() = value.toString() + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = cumulativeGroupedAllocation.validity() + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") - override fun visitPercent(percent: Percent) = percent.validity() + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && - minimumComposite == other.minimumComposite && - percent == other.percent && - eventOutput == other.eventOutput - } - - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - cumulativeGroupedAllocation, - minimumComposite, - percent, - eventOutput, - ) - - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - companion object { + fun toBuilder() = Builder().from(this) - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + companion object { - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { - @JvmStatic - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = licenseAllocation.additionalProperties.toMutableMap() + } - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) - @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } - @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmStatic - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + private var validated: Boolean = false - @JvmStatic - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + amount() + currency() + writeOffOverage() + validated = true + } - @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - @JvmStatic - fun ofCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } - @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + /** The pricing model type */ + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + companion object { - fun visitUnit(unit: NewPlanUnitPrice): T + @JvmField val UNIT = of("unit") - fun visitTiered(tiered: NewPlanTieredPrice): T + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } - fun visitBulk(bulk: NewPlanBulkPrice): T + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT + } - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + /** + * 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, + } - fun visitPackage(package_: NewPlanPackagePrice): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT -> Value.UNIT + else -> Value._UNKNOWN + } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT -> Known.UNIT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + private var validated: Boolean = false - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ModelType = apply { + if (validated) { + return@apply + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + known() + validated = true + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + return other is ModelType && value == other.value + } - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + override fun hashCode() = value.hashCode() - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + override fun toString() = value.toString() + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + fun toBuilder() = Builder().from(this) - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + companion object { - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + private var additionalProperties: MutableMap = mutableMapOf() - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitPercent(percent: Percent): T + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun visitEventOutput(eventOutput: EventOutput): T + private var validated: Boolean = false /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException in the default implementation. + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - internal class Deserializer : BaseDeserializer(Price::class) { + validated = true + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) - } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) - } - "cumulative_grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) - } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) - } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - return Price(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties } - } - internal class Serializer : BaseSerializer(Price::class) { + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.cumulativeGroupedAllocation != null -> - generator.writeObject(value.cumulativeGroupedAllocation) - value.minimumComposite != null -> - generator.writeObject(value.minimumComposite) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - class BulkWithFilters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val bulkWithFiltersConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bulkWithFiltersConfig, + return other is LicenseAllocationPrice && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3551,2162 +4253,1603 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, - mutableMapOf(), + additionalProperties, ) + } - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + override fun hashCode(): Int = hashCode - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + override fun toString() = + "LicenseAllocationPrice{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { - /** - * The pricing model type - * - * Expected to always return the following: - * ```java - * JsonValue.from("bulk_with_filters") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun unit(): Optional = Optional.ofNullable(unit) - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + fun tiered(): Optional = Optional.ofNullable(tiered) - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + fun bulk(): Optional = Optional.ofNullable(bulk) - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + fun package_(): Optional = Optional.ofNullable(package_) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + fun matrix(): Optional = Optional.ofNullable(matrix) - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun percent(): Optional = Optional.ofNullable(percent) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) - fun toBuilder() = Builder().from(this) + fun isUnit(): Boolean = unit != null - companion object { + fun isTiered(): Boolean = tiered != null - /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. - * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun isBulk(): Boolean = bulk != null - /** A builder for [BulkWithFilters]. */ - class Builder internal constructor() { + fun isBulkWithFilters(): Boolean = bulkWithFilters != null - private var bulkWithFiltersConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun isPackage(): Boolean = package_ != null - @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() - } + fun isMatrix(): Boolean = matrix != null - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + fun isTieredPackage(): Boolean = tieredPackage != null - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun isGroupedTiered(): Boolean = groupedTiered != null - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - /** - * 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("bulk_with_filters") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun isUnitWithPercent(): Boolean = unitWithPercent != null - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + fun isTieredWithProration(): Boolean = tieredWithProration != null - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + fun isUnitWithProration(): Boolean = unitWithProration != null - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + fun isGroupedAllocation(): Boolean = groupedAllocation != null - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + fun isBulkWithProration(): Boolean = bulkWithProration != null - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + fun isMeteredAllowance(): Boolean = meteredAllowance != null - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + fun isMinimumComposite(): Boolean = minimumComposite != null - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + fun isPercent(): Boolean = percent != null - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + fun isEventOutput(): Boolean = eventOutput != null - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") - /** - * Returns an immutable instance of [BulkWithFilters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewPlanUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) } - private var validated: Boolean = false + private var validated: Boolean = false - fun validate(): BulkWithFilters = apply { - if (validated) { - return@apply - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Price = apply { + if (validated) { + return@apply + } - bulkWithFiltersConfig().validate() - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } - @JsonCreator - private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } - /** - * Bulk tiers for rating based on total usage volume - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } - fun toBuilder() = Builder().from(this) + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } - companion object { + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } - /** A builder for [BulkWithFiltersConfig]. */ - class Builder internal constructor() { + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } - private var filters: JsonField>? = null - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } - @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() } - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() } - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() } - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() } - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() } - /** - * Returns an immutable instance of [BulkWithFiltersConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } - private var validated: Boolean = false + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } - fun validate(): BulkWithFiltersConfig = apply { - if (validated) { - return@apply + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() } - filters().forEach { it.validate() } - tiers().forEach { it.validate() } - validated = true - } + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + override fun visitPercent(percent: Percent) { + percent.validate() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() - fun toBuilder() = Builder().from(this) + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() - companion object { + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() - /** A builder for [Filter]. */ - class Builder internal constructor() { + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() - @JvmSynthetic - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() - private var validated: Boolean = false + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() - fun validate(): Filter = apply { - if (validated) { - return@apply - } + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() - propertyKey() - propertyValue() - validated = true - } + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (propertyKey.asKnown().isPresent) 1 else 0) + - (if (propertyValue.asKnown().isPresent) 1 else 0) + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() - override fun hashCode(): Int = hashCode + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + override fun visitPercent(percent: Percent) = percent.validity() - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + matrixWithThresholdDiscounts, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, + minimumComposite, + percent, + eventOutput, + ) - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) - fun toBuilder() = Builder().from(this) + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) - companion object { + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) - /** A builder for [Tier]. */ - class Builder internal constructor() { + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) - private var validated: Boolean = false + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) - fun validate(): Tier = apply { - if (validated) { - return@apply - } + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) - unitAmount() - tierLowerBound() - validated = true - } + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties - } + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) - override fun hashCode(): Int = hashCode + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) - } + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) - override fun hashCode(): Int = hashCode + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { - companion object { + fun visitUnit(unit: NewPlanUnitPrice): T - @JvmField val ANNUAL = of("annual") + fun visitTiered(tiered: NewPlanTieredPrice): T - @JvmField val SEMI_ANNUAL = of("semi_annual") + fun visitBulk(bulk: NewPlanBulkPrice): T - @JvmField val MONTHLY = of("monthly") + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T - @JvmField val QUARTERLY = of("quarterly") + fun visitPackage(package_: NewPlanPackagePrice): T - @JvmField val ONE_TIME = of("one_time") + fun visitMatrix(matrix: NewPlanMatrixPrice): T - @JvmField val CUSTOM = of("custom") + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T - private var validated: Boolean = false + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T - known() - validated = true - } + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T - return other is Cadence && value == other.value - } + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T - override fun hashCode() = value.hashCode() + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T - override fun toString() = value.toString() - } + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T - fun toBuilder() = Builder().from(this) + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T - companion object { + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T - private var additionalProperties: MutableMap = - mutableMapOf() + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun visitPercent(percent: Percent): T - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun visitEventOutput(eventOutput: EventOutput): T - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + internal class Deserializer : BaseDeserializer(Price::class) { - private var validated: Boolean = false + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() - fun validate(): Metadata = apply { - if (validated) { - return@apply + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) } - - return other is Metadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && - cadence == other.cadence && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - bulkWithFiltersConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - class TieredWithProration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val tieredWithProrationConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - tieredWithProrationConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + /** * The id of the item the price will be associated with. * @@ -5721,7 +5864,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5738,16 +5881,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -5852,6 +5985,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5871,6 +6012,17 @@ private constructor( */ fun referenceId(): Optional = referenceId.getOptional("reference_id") + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + /** * Returns the raw JSON value of [cadence]. * @@ -5897,17 +6049,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -6021,6 +6162,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6056,29 +6207,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. * * The following fields are required: * ```java + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [BulkWithFilters]. */ class Builder internal constructor() { + private var bulkWithFiltersConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -6096,45 +6245,60 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } @@ -6156,7 +6320,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("bulk_with_filters") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6176,22 +6340,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6540,6 +6688,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6604,27 +6773,27 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [BulkWithFilters]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .bulkWithFiltersConfig() * .cadence() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6636,6 +6805,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -6644,20 +6814,30 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): BulkWithFilters = apply { if (validated) { return@apply } + bulkWithFiltersConfig().validate() cadence().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("bulk_with_filters")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -6669,6 +6849,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -6690,13 +6871,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -6708,186 +6887,40 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val filters: JsonField>, private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), @JsonProperty("tiers") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -6895,6 +6928,16 @@ private constructor( */ fun tiers(): List = tiers.getRequired("tiers") + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + /** * Returns the raw JSON value of [tiers]. * @@ -6921,35 +6964,61 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [BulkWithFiltersConfig]. * * The following fields are required: * ```java + * .filters() * .tiers() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [BulkWithFiltersConfig]. */ class Builder internal constructor() { + private var filters: JsonField>? = null private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** @@ -6999,19 +7068,21 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [BulkWithFiltersConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .filters() * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -7019,11 +7090,22 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply } + filters().forEach { it.validate() } tiers().forEach { it.validate() } validated = true } @@ -7044,55 +7126,279 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a single tiered with proration tier */ - class Tier + /** Configuration for a single property filter */ + class Filter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, + private val propertyKey: JsonField, + private val propertyValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tier_lower_bound") + @JsonProperty("property_key") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) /** - * Inclusive tier starting value + * Event property key to filter on * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + fun propertyKey(): String = propertyKey.getRequired("property_key") /** - * Amount per unit + * Event property value to match * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun propertyValue(): String = propertyValue.getRequired("property_value") /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns the raw JSON value of [propertyKey]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has * an unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("property_value") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") /** * Returns the raw JSON value of [unitAmount]. @@ -7104,6 +7410,16 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -7123,7 +7439,6 @@ private constructor( * * The following fields are required: * ```java - * .tierLowerBound() * .unitAmount() * ``` */ @@ -7133,46 +7448,53 @@ private constructor( /** A builder for [Tier]. */ class Builder internal constructor() { - private var tierLowerBound: JsonField? = null private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound additionalProperties = tier.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed + * You should usually call [Builder.unitAmount] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed + * You should usually call [Builder.tierLowerBound] with a well-typed * [String] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound } fun additionalProperties(additionalProperties: Map) = @@ -7205,7 +7527,6 @@ private constructor( * * The following fields are required: * ```java - * .tierLowerBound() * .unitAmount() * ``` * @@ -7213,21 +7534,31 @@ private constructor( */ fun build(): Tier = Tier( - checkRequired("tierLowerBound", tierLowerBound), checkRequired("unitAmount", unitAmount), + tierLowerBound, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply } - tierLowerBound() unitAmount() + tierLowerBound() validated = true } @@ -7247,8 +7578,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -7256,19 +7587,19 @@ private constructor( } return other is Tier && - tierLowerBound == other.tierLowerBound && unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash(unitAmount, tierLowerBound, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -7276,120 +7607,302 @@ private constructor( return true } - return other is TieredWithProrationConfig && + return other is BulkWithFiltersConfig && + filters == other.filters && tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + private constructor(private val value: JsonField) : Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @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() - } + @JvmField val ANNUAL = of("annual") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val MONTHLY = of("monthly") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JvmField val QUARTERLY = of("quarterly") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val ONE_TIME = of("one_time") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val CUSTOM = of("custom") - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * Used for best match union deserialization. + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties } @@ -7405,12 +7918,12 @@ private constructor( return true } - return other is TieredWithProration && + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -7422,6 +7935,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -7429,11 +7943,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + bulkWithFiltersConfig, cadence, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -7445,6 +7959,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -7454,16 +7969,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class MatrixWithThresholdDiscounts @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -7478,6 +7993,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -7488,14 +8004,14 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -7538,6 +8054,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7546,8 +8065,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, billableMetricId, @@ -7561,6 +8080,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -7576,32 +8096,32 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for matrix_with_threshold_discounts pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7722,6 +8242,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7751,17 +8279,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -7770,6 +8287,18 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig + /** * Returns the raw JSON value of [name]. * @@ -7891,6 +8420,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7927,29 +8466,29 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [MatrixWithThresholdDiscounts]. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [MatrixWithThresholdDiscounts]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + JsonValue.from("matrix_with_threshold_discounts") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7968,37 +8507,39 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = matrixWithThresholdDiscounts.cadence + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + currency = matrixWithThresholdDiscounts.currency dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata + referenceId = matrixWithThresholdDiscounts.referenceId additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -8013,29 +8554,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -8048,13 +8566,36 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -8422,6 +8963,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -8486,28 +9048,28 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( checkRequired("cadence", cadence), + checkRequired("itemId", itemId), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, ), - checkRequired("itemId", itemId), modelType, checkRequired("name", name), billableMetricId, @@ -8521,6 +9083,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -8529,16 +9092,26 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() + matrixWithThresholdDiscountsConfig().validate() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -8554,6 +9127,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -8576,10 +9150,11 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -8593,6 +9168,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -8716,6 +9292,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -8755,108 +9341,140 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Unit price used for usage that does not match any defined matrix cell. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The maximum amount to charge each group + * First matrix dimension key. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") /** - * The minimum amount to charge each group, regardless of usage + * Per-cell unit prices. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") /** - * The base price charged per group + * Optional second matrix dimension key. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") /** - * Returns the raw JSON value of [groupingKey]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [firstDimension]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [firstDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("first_dimension") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _firstDimension(): JsonField = firstDimension /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("matrix_values") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _matrixValues(): JsonField> = matrixValues /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [secondDimension]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [secondDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("second_dimension") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -8874,246 +9492,166 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [MatrixWithThresholdDiscountsConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties + matrixWithThresholdDiscountsConfig.additionalProperties .toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Unit price used for usage that does not match any defined matrix cell. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.defaultUnitAmount] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.firstDimension] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed + * You should usually call [Builder.firstDimension] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` + * Sets [Builder.secondDimension] to an arbitrary JSON value. * - * @throws IllegalStateException if any required field is unset. + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply - } - - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } } fun additionalProperties(additionalProperties: Map) = @@ -9139,20 +9677,56 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { if (validated) { return@apply } + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } validated = true } @@ -9172,3348 +9746,2761 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + mutableMapOf(), + ) - return other is Metadata && - additionalProperties == other.additionalProperties - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - override fun hashCode(): Int = hashCode + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - return other is GroupedWithMinMaxThresholds && - cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue - private val hashCode: Int by lazy { - Objects.hash( - cadence, - groupedWithMinMaxThresholdsConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } + fun toBuilder() = Builder().from(this) - class CumulativeGroupedAllocation - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + companion object { - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - cumulativeGroupedAllocationConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { - /** - * Configuration for cumulative_grouped_allocation pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } - /** - * The pricing model type - * - * Expected to always return the following: - * ```java - * JsonValue.from("cumulative_grouped_allocation") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + private var validated: Boolean = false - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - companion object { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. - * - * The following fields are required: - * ```java - * .cadence() - * .cumulativeGroupedAllocationConfig() - * .itemId() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** A builder for [CumulativeGroupedAllocation]. */ - class Builder internal constructor() { + fun toBuilder() = Builder().from(this) - private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + companion object { - @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) - /** - * 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("cumulative_grouped_allocation") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + fun description(description: String?) = + description(JsonField.ofNullable(description)) - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + private var validated: Boolean = false - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + override fun hashCode(): Int = hashCode - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, ) + } - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + companion object { - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + private var validated: Boolean = false /** - * Sets [Builder.referenceId] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): Metadata = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .cadence() - * .cumulativeGroupedAllocationConfig() - * .itemId() - * .name() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( - checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): CumulativeGroupedAllocation = apply { - if (validated) { - return@apply + return other is Metadata && + additionalProperties == other.additionalProperties } - cadence().validate() - cumulativeGroupedAllocationConfig().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_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) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - companion object { + override fun hashCode(): Int = hashCode - @JvmField val ANNUAL = of("annual") + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - @JvmField val SEMI_ANNUAL = of("semi_annual") + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JvmField val MONTHLY = of("monthly") + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - @JvmField val QUARTERLY = of("quarterly") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - @JvmField val ONE_TIME = of("one_time") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JvmField val CUSTOM = of("custom") + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - private var validated: Boolean = false + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - known() - validated = true - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - return other is Cadence && value == other.value - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - override fun hashCode() = value.hashCode() + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - override fun toString() = value.toString() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, - private val groupingKey: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - @JsonCreator - private constructor( - @JsonProperty("cumulative_allocation") - @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") - @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - mutableMapOf(), - ) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * The overall allocation across all groups - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * The allocation per individual group + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** - * The event property used to group usage before applying allocations + * Sets [Builder.cadence] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** - * The amount to charge for each unit outside of the allocation + * Sets [Builder.itemId] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sets the field to an arbitrary JSON value. * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field - * has an unexpected type. + * 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. */ - @JsonProperty("cumulative_allocation") - @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** - * Returns the raw JSON value of [groupAllocation]. + * Sets [Builder.name] to an arbitrary JSON value. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("group_allocation") - @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) /** - * Returns the raw JSON value of [groupingKey]. + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * The id of the billable metric for the price. Only needed if the price is + * usage-based. */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - companion object { + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. - * - * The following fields are required: - * ```java - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - /** A builder for [CumulativeGroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null - private var groupingKey: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount - additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. - * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - /** The event property used to group usage before applying allocations */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The amount to charge for each unit outside of the allocation */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .cumulativeAllocation() - * .groupAllocation() - * .groupingKey() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), - checkRequired("groupingKey", groupingKey), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - private var validated: Boolean = false + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun validate(): CumulativeGroupedAllocationConfig = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - cumulativeAllocation() - groupAllocation() - groupingKey() - unitAmount() - validated = true - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - @JvmSynthetic - internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && - groupingKey == other.groupingKey && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - private val hashCode: Int by lazy { - Objects.hash( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - additionalProperties, - ) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - override fun hashCode(): Int = hashCode - - override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId } - private var validated: Boolean = false + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - validated = true - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.referenceId] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - return other is Metadata && - additionalProperties == other.additionalProperties + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - return other is CumulativeGroupedAllocation && - cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && - itemId == other.itemId && - modelType == other.modelType && - name == other.name && - billableMetricId == other.billableMetricId && - billedInAdvance == other.billedInAdvance && - billingCycleConfiguration == other.billingCycleConfiguration && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - currency == other.currency && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoiceGroupingKey == other.invoiceGroupingKey && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - metadata == other.metadata && - referenceId == other.referenceId && - additionalProperties == other.additionalProperties + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) } - private val hashCode: Int by lazy { - Objects.hash( - cadence, - cumulativeGroupedAllocationConfig, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - class Percent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val percentConfig: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - cadence, - itemId, - modelType, - name, - percentConfig, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) - - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + private var validated: Boolean = false /** - * The pricing model type + * Validates that the types of all values in this object match their expected types + * recursively. * - * Expected to always return the following: - * ```java - * JsonValue.from("percent") - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Used for best match union deserialization. */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + companion object { - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + @JvmField val ANNUAL = of("annual") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + @JvmField val SEMI_ANNUAL = of("semi_annual") - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + @JvmField val MONTHLY = of("monthly") - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + @JvmField val QUARTERLY = of("quarterly") - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + @JvmField val ONE_TIME = of("one_time") - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + @JvmField val CUSTOM = of("custom") - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig + private var validated: Boolean = false - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + known() + validated = true + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```java - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` + * Used for best match union deserialization. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Percent]. */ - class Builder internal constructor() { + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") - private var name: JsonField? = null - private var percentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmSynthetic - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() + return other is Cadence && value == other.value } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + override fun hashCode() = value.hashCode() - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + override fun toString() = value.toString() + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * Sets [Builder.itemId] to an arbitrary JSON value. + * Tiers for rating based on total usage quantities into the specified tier with + * proration * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun tiers(): List = tiers.getRequired("tiers") /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("percent") - * ``` + * Returns the raw JSON value of [tiers]. * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + private var validated: Boolean = false /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + tiers().forEach { it.validate() } + validated = true + } - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } - - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + fun toBuilder() = Builder().from(this) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + companion object { - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + private var validated: Boolean = false - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + tierLowerBound() + unitAmount() + validated = true + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * Returns an immutable instance of [Percent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .cadence() - * .itemId() - * .name() - * .percentConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Percent = - Percent( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - checkRequired("percentConfig", percentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } - private var validated: Boolean = false + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun validate(): Percent = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("percent")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - percentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) - - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ANNUAL = of("annual") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } - - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Cadence && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for percent pricing */ - class PercentConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val percent: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("percent") - @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) - - /** - * What percent of the component subtotals to charge - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun percent(): Double = percent.getRequired("percent") - - /** - * Returns the raw JSON value of [percent]. - * - * Unlike [percent], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent") - @ExcludeMissing - fun _percent(): JsonField = percent - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [PercentConfig]. - * - * The following fields are required: - * ```java - * .percent() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentConfig]. */ - class Builder internal constructor() { - - private var percent: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() - } - - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) - - /** - * Sets [Builder.percent] to an arbitrary JSON value. - * - * You should usually call [Builder.percent] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun percent(percent: JsonField) = apply { this.percent = percent } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PercentConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .percent() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PercentConfig = apply { - if (validated) { - return@apply - } - - percent() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PercentConfig && - percent == other.percent && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + 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]. */ @@ -12559,6 +12546,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -12608,12 +12605,12 @@ private constructor( return true } - return other is Percent && + return other is TieredWithProration && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12625,6 +12622,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12636,7 +12634,7 @@ private constructor( itemId, modelType, name, - percentConfig, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12648,6 +12646,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12657,14 +12656,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -12680,6 +12680,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12690,9 +12691,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -12738,6 +12741,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12746,7 +12752,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -12761,6 +12767,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12776,14 +12783,16 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for event_output pricing + * Configuration for grouped_with_min_max_thresholds pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) /** * The id of the item the price will be associated with. @@ -12799,7 +12808,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12920,6 +12929,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12950,14 +12967,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [eventOutputConfig]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("event_output_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig /** * Returns the raw JSON value of [itemId]. @@ -13088,6 +13106,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -13123,12 +13151,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() * ``` @@ -13136,13 +13165,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -13161,58 +13193,74 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } /** The id of the item the price will be associated with. */ @@ -13233,7 +13281,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13601,6 +13649,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13665,24 +13734,27 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -13697,6 +13769,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13705,16 +13778,26 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -13730,6 +13813,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13752,9 +13836,11 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -13767,6 +13853,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -13890,6 +13977,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -13929,87 +14026,108 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") - @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") - @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * The key in the event data to extract the unit rate from. + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. + * The maximum amount to charge each group * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun defaultUnitRate(): Optional = - defaultUnitRate.getOptional("default_unit_rate") + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. + * The minimum amount to charge each group, regardless of usage * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") /** - * Returns the raw JSON value of [unitRatingKey]. + * The base price charged per group * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_rating_key") + @JsonProperty("grouping_key") @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [defaultUnitRate]. + * Returns the raw JSON value of [maximumCharge]. * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("default_unit_rate") + @JsonProperty("maximum_charge") @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun _maximumCharge(): JsonField = maximumCharge /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [minimumCharge]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("minimum_charge") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -14027,97 +14145,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```java - * .unitRatingKey() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() } - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.unitRatingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Alias for calling [Builder.defaultUnitRate] with - * `defaultUnitRate.orElse(null)`. - */ - fun defaultUnitRate(defaultUnitRate: Optional) = - defaultUnitRate(defaultUnitRate.getOrNull()) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * You should usually call [Builder.defaultUnitRate] with a well-typed + * You should usually call [Builder.maximumCharge] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) /** - * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: Optional) = - groupingKey(groupingKey.getOrNull()) + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.perUnitRate] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] + * You should usually call [Builder.perUnitRate] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate } fun additionalProperties(additionalProperties: Map) = @@ -14143,36 +14264,51 @@ private constructor( } /** - * Returns an immutable instance of [EventOutputConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .unitRatingKey() + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): EventOutputConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - unitRatingKey() - defaultUnitRate() groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -14192,27 +14328,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (unitRatingKey.asKnown().isPresent) 1 else 0) + - (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && + return other is GroupedWithMinMaxThresholdsConfig && groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - unitRatingKey, - defaultUnitRate, groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, additionalProperties, ) } @@ -14220,7 +14359,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -14290,6 +14429,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -14339,9 +14488,10 @@ private constructor( return true } - return other is EventOutput && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -14356,6 +14506,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -14364,7 +14515,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -14379,6 +14530,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -14388,4659 +14540,22891 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - additionalProperties == other.additionalProperties - } + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - override fun hashCode(): Int = hashCode + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" - } + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The id of the adjustment to remove from on the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * The phase to remove this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun toBuilder() = Builder().from(this) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - companion object { + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - private var adjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - @JvmSynthetic - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - planPhaseOrder = removeAdjustment.planPhaseOrder - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - /** The id of the adjustment to remove from on the plan. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - /** The phase to remove this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var validated: Boolean = false + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - adjustmentId() - planPhaseOrder() - validated = true - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (adjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - private val hashCode: Int by lazy { - Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val priceId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JsonCreator - private constructor( - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(priceId, planPhaseOrder, mutableMapOf()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * The id of the price to remove from the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceId(): String = priceId.getRequired("price_id") + fun toBuilder() = Builder().from(this) - /** - * The phase to remove this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + companion object { - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } - fun toBuilder() = Builder().from(this) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - companion object { + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * Returns a mutable builder for constructing an instance of [RemovePrice]. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } - private var priceId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - @JvmSynthetic - internal fun from(removePrice: RemovePrice) = apply { - priceId = removePrice.priceId - planPhaseOrder = removePrice.planPhaseOrder - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The id of the price to remove from the plan. */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + /** + * 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("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** The phase to remove this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemovePrice = - RemovePrice( - checkRequired("priceId", priceId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - private var validated: Boolean = false + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - priceId() - planPhaseOrder() - validated = true - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (priceId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - return other is RemovePrice && - priceId == other.priceId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - private val hashCode: Int by lazy { - Objects.hash(priceId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun toString() = - "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val planPhaseOrder: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * The definition of a new adjustment to create and add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * The id of the adjustment on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * The phase to replace this adjustment from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var planPhaseOrder: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - planPhaseOrder = replaceAdjustment.planPhaseOrder - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** The definition of a new adjustment to create and add to the plan. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) - - /** The id of the adjustment on the plan to replace in the plan. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } - - /** The phase to replace this adjustment from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) - - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - planPhaseOrder, - additionalProperties.toMutableMap(), - ) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - private var validated: Boolean = false + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - adjustment().validate() - replacesAdjustmentId() - planPhaseOrder() - validated = true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** The definition of a new adjustment to create and add to the plan. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + private var validated: Boolean = false - fun minimum(): Optional = Optional.ofNullable(minimum) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } - fun maximum(): Optional = Optional.ofNullable(maximum) + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - fun isPercentageDiscount(): Boolean = percentageDiscount != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("cumulative_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) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - fun isAmountDiscount(): Boolean = amountDiscount != null + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun isMinimum(): Boolean = minimum != null + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the 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 isMaximum(): Boolean = maximum != null + companion object { - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + @JvmField val ANNUAL = of("annual") - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + @JvmField val MONTHLY = of("monthly") - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + @JvmField val QUARTERLY = of("quarterly") - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + @JvmField val ONE_TIME = of("one_time") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val CUSTOM = of("custom") - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - private var validated: Boolean = false + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + private var validated: Boolean = false - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = 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 = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + known() + validated = true + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun unknown(json: JsonValue?) = 0 + return other is Cadence && value == other.value } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + override fun hashCode() = value.hashCode() - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + override fun toString() = value.toString() + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - companion object { + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitMinimum(minimum: NewMinimum): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitMaximum(maximum: NewMaximum): T + fun toBuilder() = Builder().from(this) - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + companion object { - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() } - } - return Adjustment(_json = json) - } - } + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) - internal class Serializer : BaseSerializer(Adjustment::class) { + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - planPhaseOrder == other.planPhaseOrder && - additionalProperties == other.additionalProperties - } + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) - } + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun hashCode(): Int = hashCode + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val planPhaseOrder: JsonField, - private val price: JsonField, - private val additionalProperties: MutableMap, - ) { + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(replacesPriceId, allocationPrice, planPhaseOrder, price, mutableMapOf()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * The id of the price on the plan to replace in the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * The allocation price to add to the plan. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): Optional = - allocationPrice.getOptional("allocation_price") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The phase to replace this price from. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * New plan price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + private var validated: Boolean = false - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun toBuilder() = Builder().from(this) + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun hashCode(): Int = hashCode - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - planPhaseOrder = replacePrice.planPhaseOrder - price = replacePrice.price - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** The id of the price on the plan to replace in the plan. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + companion object { - /** The allocation price to add to the plan. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + private var additionalProperties: MutableMap = + mutableMapOf() - /** The phase to replace this price from. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** New plan price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + private var validated: Boolean = false - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + validated = true + } - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewPlanTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + override fun hashCode(): Int = hashCode - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewPlanGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + override fun hashCode(): Int = hashCode - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewPlanUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + class DailyCreditAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val dailyCreditAllowanceConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + dailyCreditAllowanceConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + dailyCreditAllowanceConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** + * Configuration for daily_credit_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. - */ - fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = - price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) - - /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ - fun price(minimumComposite: NewPlanMinimumCompositePrice) = - price(Price.ofMinimumComposite(minimumComposite)) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - planPhaseOrder, - price, - additionalProperties.toMutableMap(), - ) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - private var validated: Boolean = false + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - planPhaseOrder() - price().ifPresent { it.validate() } - validated = true - } + /** + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. + * + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** New plan price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun tiered(): Optional = Optional.ofNullable(tiered) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun bulk(): Optional = Optional.ofNullable(bulk) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun package_(): Optional = Optional.ofNullable(package_) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - fun matrix(): Optional = Optional.ofNullable(matrix) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + fun toBuilder() = Builder().from(this) - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + companion object { - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun groupedWithProratedMinimum(): Optional = - Optional.ofNullable(groupedWithProratedMinimum) + /** A builder for [DailyCreditAllowance]. */ + class Builder internal constructor() { - fun groupedWithMeteredMinimum(): Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + private var cadence: JsonField? = null + private var dailyCreditAllowanceConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun groupedWithMinMaxThresholds(): Optional = - Optional.ofNullable(groupedWithMinMaxThresholds) + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + currency = dailyCreditAllowance.currency + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + referenceId = dailyCreditAllowance.referenceId + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + /** + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun cumulativeGroupedAllocation(): Optional = - Optional.ofNullable(cumulativeGroupedAllocation) + /** + * 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("daily_credit_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun minimumComposite(): Optional = - Optional.ofNullable(minimumComposite) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun percent(): Optional = Optional.ofNullable(percent) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun isUnit(): Boolean = unit != null + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - fun isTiered(): Boolean = tiered != null + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun isBulk(): Boolean = bulk != null + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun isPackage(): Boolean = package_ != null + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun isMatrix(): Boolean = matrix != null + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun isMinimumComposite(): Boolean = minimumComposite != null + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun isPercent(): Boolean = percent != null + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun isEventOutput(): Boolean = eventOutput != null + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Returns an immutable instance of [DailyCreditAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowance = + DailyCreditAllowance( + checkRequired("cadence", cadence), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + private var validated: Boolean = false - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { + if (validated) { + return@apply + } - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + cadence().validate() + dailyCreditAllowanceConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("daily_credit_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - - fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = - cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asMinimumComposite(): NewPlanMinimumCompositePrice = - minimumComposite.getOrThrow("minimumComposite") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - fun asPercent(): Percent = percent.getOrThrow("percent") + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the 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 _json(): Optional = Optional.ofNullable(_json) + companion object { - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - cumulativeGroupedAllocation != null -> - visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) - minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } + @JvmField val ANNUAL = of("annual") - private var validated: Boolean = false + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun validate(): Price = apply { - if (validated) { - return@apply - } + @JvmField val MONTHLY = of("monthly") - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + @JvmField val QUARTERLY = of("quarterly") - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + @JvmField val ONE_TIME = of("one_time") - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + @JvmField val CUSTOM = of("custom") - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + private var validated: Boolean = false - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + known() + validated = true + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + return other is Cadence && value == other.value + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + override fun hashCode() = value.hashCode() - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + override fun toString() = value.toString() + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, + private val additionalProperties: MutableMap, + ) { - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + @JsonCreator + private constructor( + @JsonProperty("daily_allowance") + @ExcludeMissing + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") + @ExcludeMissing + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** + * Credits granted per day. Lose-it-or-use-it; does not roll over. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + /** + * One or two event property values to evaluate matrix groups by + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensions(): List = dimensions.getRequired("dimensions") - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** + * Per-dimension credit rates + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("daily_allowance") + @ExcludeMissing + fun _dailyAllowance(): JsonField = dailyAllowance - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) { - cumulativeGroupedAllocation.validate() - } + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { - minimumComposite.validate() - } + /** + * Returns the raw JSON value of [eventDayProperty]. + * + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_day_property") + @ExcludeMissing + fun _eventDayProperty(): JsonField = eventDayProperty - override fun visitPercent(percent: Percent) { - percent.validate() - } + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + fun toBuilder() = Builder().from(this) - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + companion object { - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowanceConfig]. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + /** A builder for [DailyCreditAllowanceConfig]. */ + class Builder internal constructor() { - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + @JvmSynthetic + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + /** + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance + } - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() - - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * Sets [Builder.dimensions] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + private var validated: Boolean = false - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = cumulativeGroupedAllocation.validity() + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitPercent(percent: Percent) = percent.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && - minimumComposite == other.minimumComposite && - percent == other.percent && - eventOutput == other.eventOutput - } + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - cumulativeGroupedAllocation, - minimumComposite, - percent, - eventOutput, - ) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + fun toBuilder() = Builder().from(this) - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + companion object { - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { - @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } - @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) - @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - Price(matrixWithAllocation = matrixWithAllocation) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JvmStatic - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + private var validated: Boolean = false - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + dimensionValues() + unitAmount() + validated = true + } - @JvmStatic - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) - @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - Price(groupedTieredPackage = groupedTieredPackage) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - @JvmStatic - fun ofCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties + } - @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + private val hashCode: Int by lazy { + Objects.hash( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + additionalProperties, + ) + } - @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + override fun hashCode(): Int = hashCode - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + override fun toString() = + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" + } - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitTiered(tiered: NewPlanTieredPrice): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitBulk(bulk: NewPlanBulkPrice): T + fun toBuilder() = Builder().from(this) - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + companion object { - fun visitPackage(package_: NewPlanPackagePrice): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + private var validated: Boolean = false - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + validated = true + } - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + return other is Metadata && + additionalProperties == other.additionalProperties + } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + override fun hashCode(): Int = hashCode - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + return other is DailyCreditAllowance && + cadence == other.cadence && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + private val hashCode: Int by lazy { + Objects.hash( + cadence, + dailyCreditAllowanceConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ): T + override fun hashCode(): Int = hashCode - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + override fun toString() = + "DailyCreditAllowance{cadence=$cadence, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - fun visitPercent(percent: Percent): T + class MeteredAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun visitEventOutput(eventOutput: EventOutput): T + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + meteredAllowanceConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) /** - * Maps an unknown variant of [Price] to a value of type [T]. + * The cadence to bill for this price on. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. * - * @throws OrbInvalidDataException in the default implementation. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun itemId(): String = itemId.getRequired("item_id") - internal class Deserializer : BaseDeserializer(Price::class) { + /** + * Configuration for metered_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("metered_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(unit = it, _json = json) - } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(tiered = it, _json = json) - } ?: Price(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulk = it, _json = json) - } ?: Price(_json = json) - } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(matrix = it, _json = json) - } ?: Price(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .meteredAllowanceConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MeteredAllowance]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + currency = meteredAllowance.currency + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + referenceId = meteredAllowance.referenceId + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + + /** + * 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("metered_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MeteredAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .meteredAllowanceConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MeteredAllowance = + MeteredAllowance( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + meteredAllowanceConfig().validate() + _modelType().let { + if (it != JsonValue.from("metered_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowance_grouping_value") + @ExcludeMissing + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") + @ExcludeMissing + consumptionGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), + ) : this( + allowanceGroupingValue, + consumptionGroupingValue, + groupingKey, + unitAmount, + allowanceDisplayName, + consumptionDisplayName, + mutableMapOf(), + ) + + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") + + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") + + /** + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Per-unit price applied to gross consumption and to the allowance credit. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_grouping_value") + @ExcludeMissing + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue + + /** + * Returns the raw JSON value of [consumptionGroupingValue]. + * + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumption_grouping_value") + @ExcludeMissing + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MeteredAllowanceConfig]. + * + * The following fields are required: + * ```java + * .allowanceGroupingValue() + * .consumptionGroupingValue() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MeteredAllowanceConfig]. */ + class Builder internal constructor() { + + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName + additionalProperties = + meteredAllowanceConfig.additionalProperties.toMutableMap() + } + + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) + + /** + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } + + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) + + /** + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } + + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MeteredAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowanceGroupingValue() + * .consumptionGroupingValue() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { + if (validated) { + return@apply + } + + allowanceGroupingValue() + consumptionGroupingValue() + groupingKey() + unitAmount() + allowanceDisplayName() + consumptionDisplayName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowanceGroupingValue, + consumptionGroupingValue, + groupingKey, + unitAmount, + allowanceDisplayName, + consumptionDisplayName, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MeteredAllowance && + cadence == other.cadence && + itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + meteredAllowanceConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MeteredAllowance{cadence=$cadence, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Percent]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) + + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Percent = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) + + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") + + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { + + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } + + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) + + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } + + percent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutput]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) + + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } + + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() + } + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey + } + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate + } + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply + } + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AddPrice && + allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the adjustment to remove from on the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * The phase to remove this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + planPhaseOrder = removeAdjustment.planPhaseOrder + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove from on the plan. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + /** The phase to remove this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (adjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val priceId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(priceId, planPhaseOrder, mutableMapOf()) + + /** + * The id of the price to remove from the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceId(): String = priceId.getRequired("price_id") + + /** + * The phase to remove this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemovePrice]. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var priceId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removePrice: RemovePrice) = apply { + priceId = removePrice.priceId + planPhaseOrder = removePrice.planPhaseOrder + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The id of the price to remove from the plan. */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** The phase to remove this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemovePrice = + RemovePrice( + checkRequired("priceId", priceId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + priceId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (priceId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + priceId == other.priceId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(priceId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{priceId=$priceId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val planPhaseOrder: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, planPhaseOrder, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * The phase to replace this adjustment from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var planPhaseOrder: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + planPhaseOrder = replaceAdjustment.planPhaseOrder + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the plan. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the plan. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + /** The phase to replace this adjustment from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + planPhaseOrder, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + planPhaseOrder() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + /** The definition of a new adjustment to create and add to the plan. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(maximum) + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + planPhaseOrder == other.planPhaseOrder && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, planPhaseOrder, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, planPhaseOrder=$planPhaseOrder, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, + private val planPhaseOrder: JsonField, + private val price: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): Optional = + allocationPrice.getOptional("allocation_price") + + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + + /** + * The phase to replace this price from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * New plan price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Optional = price.getOptional("price") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + licenseAllocationPrice = replacePrice.licenseAllocationPrice + planPhaseOrder = replacePrice.planPhaseOrder + price = replacePrice.price + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the plan. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The allocation price to add to the plan. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + + /** The phase to replace this price from. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** New plan price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewPlanUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewPlanTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewPlanBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewPlanPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewPlanMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewPlanTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewPlanGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewPlanPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewPlanUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewPlanUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewPlanGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewPlanBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price(scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ + fun price(minimumComposite: NewPlanMinimumCompositePrice) = + price(Price.ofMinimumComposite(minimumComposite)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } + planPhaseOrder() + price().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + /** The license allocation price to add to the plan. */ + class LicenseAllocationPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonField, + private val name: JsonField, + private val unitConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * License allocations to associate with this price. Each entry defines a per-license + * credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") + + /** + * The pricing model type + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations + + /** + * Returns the raw JSON value of [modelType]. + * + * Unlike [modelType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocationPrice: LicenseAllocationPrice) = apply { + cadence = licenseAllocationPrice.cadence + itemId = licenseAllocationPrice.itemId + licenseAllocations = + licenseAllocationPrice.licenseAllocations.map { it.toMutableList() } + modelType = licenseAllocationPrice.modelType + name = licenseAllocationPrice.name + unitConfig = licenseAllocationPrice.unitConfig + billableMetricId = licenseAllocationPrice.billableMetricId + billedInAdvance = licenseAllocationPrice.billedInAdvance + billingCycleConfiguration = licenseAllocationPrice.billingCycleConfiguration + conversionRate = licenseAllocationPrice.conversionRate + conversionRateConfig = licenseAllocationPrice.conversionRateConfig + currency = licenseAllocationPrice.currency + dimensionalPriceConfiguration = + licenseAllocationPrice.dimensionalPriceConfiguration + externalPriceId = licenseAllocationPrice.externalPriceId + fixedPriceQuantity = licenseAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = licenseAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = licenseAllocationPrice.invoicingCycleConfiguration + licenseTypeId = licenseAllocationPrice.licenseTypeId + metadata = licenseAllocationPrice.metadata + referenceId = licenseAllocationPrice.referenceId + additionalProperties = + licenseAllocationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) + + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } + + /** The pricing model type */ + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + /** + * Sets [Builder.modelType] to an arbitrary JSON value. + * + * You should usually call [Builder.modelType] with a well-typed [ModelType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocationPrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocationPrice = + LicenseAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseAllocationPrice = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + modelType().validate() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) + + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = licenseAllocation.additionalProperties.toMutableMap() + } + + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) + + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) + + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) + + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } + + amount() + currency() + writeOffOverage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" + } + + /** The pricing model type */ + 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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ModelType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ModelType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseAllocationPrice && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocationPrice{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + /** New plan price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewPlanUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + matrixWithThresholdDiscounts, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = Price(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + @JvmStatic fun ofPackage(package_: NewPlanPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { return tryDeserialize( node, jacksonTypeRef(), ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithThresholdDiscounts + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Configuration for matrix_with_threshold_discounts pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_threshold_discounts") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscounts]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscounts]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null + private var modelType: JsonValue = + JsonValue.from("matrix_with_threshold_discounts") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = + apply { + cadence = matrixWithThresholdDiscounts.cadence + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance + billingCycleConfiguration = + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + currency = matrixWithThresholdDiscounts.currency + dimensionalPriceConfiguration = + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata + referenceId = matrixWithThresholdDiscounts.referenceId + additionalProperties = + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + + /** + * 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_with_threshold_discounts") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired( + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + matrixWithThresholdDiscountsConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) + + /** + * Unit price used for usage that does not match any defined matrix cell. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** + * First matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Per-cell unit prices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Optional second matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscountsConfig]. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ + class Builder internal constructor() { + + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = apply { + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } + additionalProperties = + matrixWithThresholdDiscountsConfig.additionalProperties + .toMutableMap() + } + + /** + * Unit price used for usage that does not match any defined matrix cell. + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "cumulative_grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) - } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) - } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - return Price(_json = json) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) } - } - internal class Serializer : BaseSerializer(Price::class) { + private var validated: Boolean = false - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.cumulativeGroupedAllocation != null -> - generator.writeObject(value.cumulativeGroupedAllocation) - value.minimumComposite != null -> - generator.writeObject(value.minimumComposite) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true } - } - class BulkWithFilters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val bulkWithFiltersConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator - private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bulkWithFiltersConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + @JvmField val SEMI_ANNUAL = of("semi_annual") - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + @JvmField val MONTHLY = of("monthly") - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JvmField val QUARTERLY = of("quarterly") - /** - * The pricing model type - * - * Expected to always return the following: - * ```java - * JsonValue.from("bulk_with_filters") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + @JvmField val ONE_TIME = of("one_time") - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + @JvmField val CUSTOM = of("custom") - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + private var validated: Boolean = false - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + known() + validated = true + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + return other is Cadence && value == other.value + } - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + companion object { - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithFilters]. */ - class Builder internal constructor() { - - private var bulkWithFiltersConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + tiers().forEach { it.validate() } + validated = true } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * 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("bulk_with_filters") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + companion object { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + companion object { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + private var additionalProperties: MutableMap = + mutableMapOf() - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + private var validated: Boolean = false /** - * Alias for [Builder.fixedPriceQuantity]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + validated = true + } - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + override fun hashCode(): Int = hashCode - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Returns an immutable instance of [BulkWithFilters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - private var validated: Boolean = false + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun validate(): BulkWithFilters = apply { - if (validated) { - return@apply - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - bulkWithFiltersConfig().validate() - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * The configuration for the rate of the price currency to the invoicing currency. * - * Used for best match union deserialization. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JvmSynthetic - internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - @JsonCreator - private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Bulk tiers for rating based on total usage volume - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - fun toBuilder() = Builder().from(this) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - companion object { + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** A builder for [BulkWithFiltersConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var filters: JsonField>? = null - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns an immutable instance of [BulkWithFiltersConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun validate(): BulkWithFiltersConfig = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - filters().forEach { it.validate() } - tiers().forEach { it.validate() } - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * - * Used for best match union deserialization. + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` */ - @JvmSynthetic - internal fun validity(): Int = - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) + @JvmStatic fun builder() = Builder() + } - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - companion object { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** A builder for [Filter]. */ - class Builder internal constructor() { + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JvmSynthetic - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): Filter = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - propertyKey() - propertyValue() - validated = true - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (propertyKey.asKnown().isPresent) 1 else 0) + - (if (propertyValue.asKnown().isPresent) 1 else 0) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - companion object { + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** A builder for [Tier]. */ - class Builder internal constructor() { + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - private var validated: Boolean = false + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun validate(): Tier = apply { - if (validated) { - return@apply - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - unitAmount() - tierLowerBound() - validated = true - } + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) /** The cadence to bill for this price on. */ class Cadence @@ -19162,6 +37546,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -19201,6 +37595,342 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -19268,6 +37998,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -19317,9 +38057,10 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -19334,6 +38075,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -19341,8 +38083,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -19357,6 +38099,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -19366,17 +38109,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -19389,6 +38133,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -19399,6 +38144,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -19408,10 +38158,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -19448,6 +38194,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -19456,10 +38205,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -19471,6 +38220,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -19485,6 +38235,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -19499,7 +38261,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -19516,16 +38278,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -19630,6 +38382,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -19659,6 +38419,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -19675,17 +38446,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -19799,6 +38559,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -19835,28 +38605,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -19874,35 +38646,40 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -19916,6 +38693,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -19934,7 +38734,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -19954,22 +38754,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -20318,6 +39102,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -20382,27 +39187,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -20414,6 +39222,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -20422,20 +39231,30 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -20447,6 +39266,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -20469,12 +39289,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -20486,6 +39306,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -20609,6 +39430,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -20648,40 +39479,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("cumulative_allocation") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [tiers]. + * The allocation per individual group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -20699,59 +39605,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -20777,32 +39724,51 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -20822,249 +39788,38 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -21134,6 +39889,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -21183,12 +39948,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -21200,6 +39966,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -21208,10 +39975,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -21223,6 +39990,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -21232,15 +40000,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class DailyCreditAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val dailyCreditAllowanceConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -21256,6 +40023,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -21266,10 +40034,9 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = + dailyCreditAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -21316,6 +40083,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -21324,7 +40094,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -21339,6 +40109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -21354,16 +40125,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for daily_credit_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") /** * The id of the item the price will be associated with. @@ -21379,7 +40148,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -21500,6 +40269,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -21530,15 +40307,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig /** * Returns the raw JSON value of [itemId]. @@ -21669,6 +40446,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -21705,12 +40492,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [DailyCreditAllowance]. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` @@ -21718,16 +40505,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [DailyCreditAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = + private var dailyCreditAllowanceConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -21746,38 +40531,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + currency = dailyCreditAllowance.currency + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + referenceId = dailyCreditAllowance.referenceId + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -21791,28 +40575,22 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -21832,7 +40610,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -22200,6 +40978,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -22264,27 +41063,24 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [DailyCreditAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): DailyCreditAllowance = + DailyCreditAllowance( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -22299,6 +41095,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -22307,16 +41104,26 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + dailyCreditAllowanceConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("daily_credit_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -22332,6 +41139,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -22354,10 +41162,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -22371,6 +41179,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -22494,6 +41303,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -22533,108 +41352,144 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Credits granted per day. Lose-it-or-use-it; does not roll over. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") /** - * The maximum amount to charge each group + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The minimum amount to charge each group, regardless of usage + * One or two event property values to evaluate matrix groups by * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun dimensions(): List = dimensions.getRequired("dimensions") /** - * The base price charged per group + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") /** - * Returns the raw JSON value of [groupingKey]. + * Per-dimension credit rates * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _dailyAllowance(): JsonField = dailyAllowance /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("dimensions") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _dimensions(): JsonField> = dimensions /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [eventDayProperty]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("event_day_property") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _eventDayProperty(): JsonField = eventDayProperty /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("matrix_values") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _matrixValues(): JsonField> = matrixValues @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -22652,100 +41507,583 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [DailyCreditAllowanceConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [DailyCreditAllowanceConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.defaultUnitAmount] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.dimensions] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) + + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + dimensionValues() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -22771,161 +42109,25 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply - } - - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Validates that the types of all values in this object match their expected + * types recursively. * - * Used for best match union deserialization. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - fun validate(): Metadata = apply { if (validated) { return@apply @@ -22975,10 +42177,9 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is DailyCreditAllowance && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -22993,6 +42194,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -23001,7 +42203,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -23016,6 +42218,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -23025,16 +42228,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -23049,6 +42251,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -23059,14 +42262,12 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -23109,6 +42310,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23117,8 +42321,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -23132,6 +42336,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23147,32 +42352,30 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for metered_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -23293,6 +42496,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -23322,17 +42533,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [itemId]. * @@ -23341,6 +42541,17 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + /** * Returns the raw JSON value of [name]. * @@ -23462,6 +42673,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -23497,30 +42718,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -23539,38 +42756,35 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + currency = meteredAllowance.currency + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + referenceId = meteredAllowance.referenceId + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -23584,29 +42798,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -23619,13 +42810,28 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + /** * 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("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -23993,6 +43199,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -24057,28 +43284,25 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), modelType, checkRequired("name", name), billableMetricId, @@ -24092,6 +43316,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -24100,16 +43325,26 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() itemId() + meteredAllowanceConfig().validate() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -24125,6 +43360,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -24147,11 +43383,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -24164,6 +43398,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -24287,6 +43522,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -24326,60 +43571,76 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), ) : this( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, mutableMapOf(), ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -24388,7 +43649,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -24397,24 +43658,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -24436,6 +43715,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -24452,12 +43751,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -24465,61 +43764,75 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) @@ -24534,7 +43847,9 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -24548,6 +43863,37 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -24571,41 +43917,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -24625,30 +43985,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -24656,7 +44022,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } /** @@ -24726,6 +44092,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -24775,11 +44151,10 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -24793,6 +44168,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -24801,8 +44177,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -24816,6 +44192,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -24825,7 +44202,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MeteredAllowance{cadence=$cadence, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -24848,6 +44225,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -24906,6 +44284,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -24929,6 +44310,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -25087,6 +44469,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -25255,6 +44645,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25328,6 +44728,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -25350,6 +44751,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -25768,6 +45170,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -25864,6 +45287,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -25872,6 +45296,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -25897,6 +45331,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -25934,6 +45369,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -26057,6 +45493,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -26224,6 +45670,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -26337,6 +45793,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -26403,6 +45869,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26426,6 +45893,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26435,7 +45903,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -26458,6 +45926,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26516,6 +45985,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26539,6 +46011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -26698,6 +46171,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -26866,6 +46347,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -26939,6 +46430,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -26961,6 +46453,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -27379,6 +46872,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27475,6 +46989,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27483,6 +46998,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -27508,6 +47033,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -27545,6 +47071,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -27668,6 +47195,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -27943,6 +47480,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -28068,6 +47615,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -28134,6 +47691,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -28157,6 +47715,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -28166,7 +47725,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -28178,6 +47737,7 @@ private constructor( return other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties @@ -28187,6 +47747,7 @@ private constructor( Objects.hash( replacesPriceId, allocationPrice, + licenseAllocationPrice, planPhaseOrder, price, additionalProperties, @@ -28196,7 +47757,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt index 3356fe15f..4a9a4580a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaExternalPlanIdSetDefaultPlanVersionParams.kt @@ -380,6 +380,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt index 4789030d4..21f458007 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BetaSetDefaultPlanVersionParams.kt @@ -376,6 +376,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt index b06b0d7cc..651382aae 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt @@ -11,6 +11,7 @@ import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException @@ -32,6 +33,7 @@ private constructor( private val metadata: JsonField, private val name: JsonField, private val status: JsonField, + private val parameterDefinitions: JsonField>, private val additionalProperties: MutableMap, ) { @@ -45,7 +47,10 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - ) : this(id, description, item, metadata, name, status, mutableMapOf()) + @JsonProperty("parameter_definitions") + @ExcludeMissing + parameterDefinitions: JsonField> = JsonMissing.of(), + ) : this(id, description, item, metadata, name, status, parameterDefinitions, mutableMapOf()) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -91,6 +96,13 @@ private constructor( */ fun status(): Status = status.getRequired("status") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun parameterDefinitions(): Optional> = + parameterDefinitions.getOptional("parameter_definitions") + /** * Returns the raw JSON value of [id]. * @@ -133,6 +145,16 @@ private constructor( */ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + /** + * Returns the raw JSON value of [parameterDefinitions]. + * + * Unlike [parameterDefinitions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parameter_definitions") + @ExcludeMissing + fun _parameterDefinitions(): JsonField> = parameterDefinitions + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -172,6 +194,7 @@ private constructor( private var metadata: JsonField? = null private var name: JsonField? = null private var status: JsonField? = null + private var parameterDefinitions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -182,6 +205,7 @@ private constructor( metadata = billableMetric.metadata name = billableMetric.name status = billableMetric.status + parameterDefinitions = billableMetric.parameterDefinitions.map { it.toMutableList() } additionalProperties = billableMetric.additionalProperties.toMutableMap() } @@ -260,6 +284,40 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } + fun parameterDefinitions(parameterDefinitions: List?) = + parameterDefinitions(JsonField.ofNullable(parameterDefinitions)) + + /** + * Alias for calling [Builder.parameterDefinitions] with + * `parameterDefinitions.orElse(null)`. + */ + fun parameterDefinitions(parameterDefinitions: Optional>) = + parameterDefinitions(parameterDefinitions.getOrNull()) + + /** + * Sets [Builder.parameterDefinitions] to an arbitrary JSON value. + * + * You should usually call [Builder.parameterDefinitions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun parameterDefinitions(parameterDefinitions: JsonField>) = + apply { + this.parameterDefinitions = parameterDefinitions.map { it.toMutableList() } + } + + /** + * Adds a single [ParameterDefinition] to [parameterDefinitions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParameterDefinition(parameterDefinition: ParameterDefinition) = apply { + parameterDefinitions = + (parameterDefinitions ?: JsonField.of(mutableListOf())).also { + checkKnown("parameterDefinitions", it).add(parameterDefinition) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -304,12 +362,21 @@ private constructor( checkRequired("metadata", metadata), checkRequired("name", name), checkRequired("status", status), + (parameterDefinitions ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): BillableMetric = apply { if (validated) { return@apply @@ -321,6 +388,7 @@ private constructor( metadata().validate() name() status().validate() + parameterDefinitions().ifPresent { it.forEach { it.validate() } } validated = true } @@ -344,7 +412,8 @@ private constructor( (item.asKnown().getOrNull()?.validity() ?: 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + + (parameterDefinitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) /** * User specified key-value pairs for the resource. If not present, this defaults to an empty @@ -409,6 +478,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -542,6 +620,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -580,6 +667,116 @@ private constructor( override fun toString() = value.toString() } + class ParameterDefinition + @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 [ParameterDefinition]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ParameterDefinition]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(parameterDefinition: ParameterDefinition) = apply { + additionalProperties = parameterDefinition.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 [ParameterDefinition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ParameterDefinition = + ParameterDefinition(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ParameterDefinition = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ParameterDefinition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ParameterDefinition{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -592,15 +789,25 @@ private constructor( metadata == other.metadata && name == other.name && status == other.status && + parameterDefinitions == other.parameterDefinitions && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, description, item, metadata, name, status, additionalProperties) + Objects.hash( + id, + description, + item, + metadata, + name, + status, + parameterDefinitions, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "BillableMetric{id=$id, description=$description, item=$item, metadata=$metadata, name=$name, status=$status, additionalProperties=$additionalProperties}" + "BillableMetric{id=$id, description=$description, item=$item, metadata=$metadata, name=$name, status=$status, parameterDefinitions=$parameterDefinitions, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt index 555c0bfdb..38b7fd344 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTiny.kt @@ -124,6 +124,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): BillableMetricTiny = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt index 55602b02b..d6b2afd15 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfiguration.kt @@ -232,6 +232,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): BillingCycleAnchorConfiguration = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt index 30a3aaa60..f763621fa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfiguration.kt @@ -166,6 +166,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): BillingCycleConfiguration = apply { if (validated) { return@apply @@ -283,6 +291,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DurationUnit = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt index 28f970b20..130a744ba 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleRelativeDate.kt @@ -98,6 +98,14 @@ private constructor(private val value: JsonField) : Enum { private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): BillingCycleRelativeDate = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt index cf86e68b5..7ce56047f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfig.kt @@ -147,6 +147,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): BulkConfig = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt index 0b67361ef..cd0270011 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkTier.kt @@ -184,6 +184,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): BulkTier = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt index 6e3c85721..93bf17829 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ChangedSubscriptionResources.kt @@ -331,6 +331,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): ChangedSubscriptionResources = apply { if (validated) { return@apply @@ -693,11 +701,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -709,6 +719,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -739,9 +750,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -759,6 +772,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -790,6 +804,11 @@ private constructor( * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the * first discount in the list will be returned. If the list is empty, `None` will be * returned. + * + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = createdInvoice.discount().convert(MyClass.class); + * ``` */ @Deprecated("deprecated") @JsonProperty("discount") @@ -1791,11 +1810,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1807,6 +1828,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1837,9 +1859,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1857,6 +1881,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -2650,6 +2675,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CreatedInvoice = apply { if (validated) { return@apply @@ -3056,6 +3090,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AutoCollection = apply { if (validated) { return@apply @@ -3458,6 +3502,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CreditNote = apply { if (validated) { return@apply @@ -4032,6 +4086,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CustomerBalanceTransaction = apply { if (validated) { return@apply @@ -4218,6 +4282,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Action = apply { if (validated) { return@apply @@ -4348,6 +4422,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Type = apply { if (validated) { return@apply @@ -4524,6 +4608,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InvoiceSource = apply { if (validated) { return@apply @@ -5336,6 +5430,13 @@ private constructor( fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with * `Price.ofTieredWithProration(tieredWithProration)`. @@ -5431,6 +5532,17 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with + * `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: Price.MinimumComposite) = price(Price.ofMinimumComposite(minimumComposite)) @@ -5662,6 +5774,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): LineItem = apply { if (validated) { return@apply @@ -5771,6 +5893,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitUsageDiscount(MonetaryUsageDiscountAdjustment usageDiscount) { + * return Optional.of(usageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) @@ -5784,6 +5936,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -6064,6 +6226,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = subLineItem.accept(new SubLineItem.Visitor>() { + * @Override + * public Optional visitMatrix(MatrixSubLineItem matrix) { + * return Optional.of(matrix.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { matrix != null -> visitor.visitMatrix(matrix) @@ -6074,6 +6266,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): SubLineItem = apply { if (validated) { return@apply @@ -6351,6 +6553,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -6787,6 +6999,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentAttempt = apply { if (validated) { return@apply @@ -6917,6 +7139,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply @@ -7097,6 +7329,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt index ae82e68e6..23f7e96e9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateConfig.kt @@ -41,6 +41,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = conversionRateConfig.accept(new ConversionRateConfig.Visitor>() { + * @Override + * public Optional visitUnit(UnitConversionRateConfig unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and the + * current variant is unknown. + */ fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) @@ -50,6 +79,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): ConversionRateConfig = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt index 18fbc5206..454d0aaa0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTier.kt @@ -210,6 +210,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): ConversionRateTier = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt index 6f337adb5..017f7e801 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateTieredConfig.kt @@ -148,6 +148,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): ConversionRateTieredConfig = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt index 2f055ec6c..3dfc04c88 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ConversionRateUnitConfig.kt @@ -133,6 +133,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): ConversionRateUnitConfig = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt index 585839497..1b2dadc15 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt @@ -469,6 +469,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Coupon = apply { if (validated) { return@apply @@ -530,6 +538,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = discount.accept(new Discount.Visitor>() { + * @Override + * public Optional visitPercentage(PercentageDiscount percentage) { + * return Optional.of(percentage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentage != null -> visitor.visitPercentage(percentage) @@ -539,6 +576,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Discount = apply { if (validated) { return@apply 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 3f2b4087c..615d3baf3 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 @@ -708,6 +708,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -793,6 +802,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = discount.accept(new Discount.Visitor>() { + * @Override + * public Optional visitPercentage(Percentage percentage) { + * return Optional.of(percentage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentage != null -> visitor.visitPercentage(percentage) @@ -802,6 +840,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Discount = apply { if (validated) { return@apply @@ -1097,6 +1144,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Percentage = apply { if (validated) { return@apply @@ -1312,6 +1369,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Amount = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt index a6d3b3429..7857dbe92 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageResponse.kt @@ -185,6 +185,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CouponListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt index 5cd99644c..df7da94e7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt @@ -14,7 +14,7 @@ import kotlin.jvm.optionals.getOrNull * * The list of coupons is ordered starting from the most recently created coupon. The response also * includes `pagination_metadata`, which lets the caller retrieve the next page of results if they - * exist. More information about pagination can be found in the Pagination-metadata schema. + * exist. */ class CouponListParams private constructor( diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt index 525f23c70..a11f59dc9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemption.kt @@ -201,6 +201,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CouponRedemption = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt index 046f82f84..a4a973871 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockExpiryLedgerEntry.kt @@ -574,6 +574,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CreditBlockExpiryLedgerEntry = apply { if (validated) { return@apply @@ -713,6 +721,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryStatus = apply { if (validated) { return@apply @@ -833,6 +850,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryType = apply { if (validated) { return@apply @@ -934,6 +960,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt new file mode 100644 index 000000000..cf7a82afe --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesParams.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +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 the credit block and its associated purchasing invoices. + * + * If a credit block was purchased (as opposed to being manually added), this endpoint returns the + * invoices that were created to charge the customer for the credit block. For credit blocks with + * payment schedules spanning multiple periods (e.g., monthly payments over 12 months), multiple + * invoices will be returned. + * + * For credit blocks created by subscription allocation prices, this endpoint returns the + * subscription invoice containing the allocation line item that created the block. + * + * If the credit block was not purchased (e.g., manual increment), an empty invoices list is + * returned. + * + * **Note: This endpoint is currently experimental and its interface may change in future releases. + * Please contact support before building production integrations against this endpoint.** + */ +class CreditBlockListInvoicesParams +private constructor( + private val blockId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun blockId(): Optional = Optional.ofNullable(blockId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CreditBlockListInvoicesParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CreditBlockListInvoicesParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditBlockListInvoicesParams]. */ + class Builder internal constructor() { + + private var blockId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(creditBlockListInvoicesParams: CreditBlockListInvoicesParams) = apply { + blockId = creditBlockListInvoicesParams.blockId + additionalHeaders = creditBlockListInvoicesParams.additionalHeaders.toBuilder() + additionalQueryParams = creditBlockListInvoicesParams.additionalQueryParams.toBuilder() + } + + fun blockId(blockId: String?) = apply { this.blockId = blockId } + + /** Alias for calling [Builder.blockId] with `blockId.orElse(null)`. */ + fun blockId(blockId: Optional) = blockId(blockId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CreditBlockListInvoicesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreditBlockListInvoicesParams = + CreditBlockListInvoicesParams( + blockId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> blockId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditBlockListInvoicesParams && + blockId == other.blockId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(blockId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CreditBlockListInvoicesParams{blockId=$blockId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt new file mode 100644 index 000000000..db19c07fd --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponse.kt @@ -0,0 +1,2109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CreditBlockListInvoicesResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val block: JsonField, + private val invoices: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("block") @ExcludeMissing block: JsonField = JsonMissing.of(), + @JsonProperty("invoices") + @ExcludeMissing + invoices: JsonField> = JsonMissing.of(), + ) : this(block, invoices, mutableMapOf()) + + /** + * The Credit Block resource models prepaid credits within Orb. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun block(): Block = block.getRequired("block") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoices(): List = invoices.getRequired("invoices") + + /** + * Returns the raw JSON value of [block]. + * + * Unlike [block], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("block") @ExcludeMissing fun _block(): JsonField = block + + /** + * Returns the raw JSON value of [invoices]. + * + * Unlike [invoices], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoices") @ExcludeMissing fun _invoices(): JsonField> = invoices + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CreditBlockListInvoicesResponse]. + * + * The following fields are required: + * ```java + * .block() + * .invoices() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditBlockListInvoicesResponse]. */ + class Builder internal constructor() { + + private var block: JsonField? = null + private var invoices: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditBlockListInvoicesResponse: CreditBlockListInvoicesResponse) = + apply { + block = creditBlockListInvoicesResponse.block + invoices = creditBlockListInvoicesResponse.invoices.map { it.toMutableList() } + additionalProperties = + creditBlockListInvoicesResponse.additionalProperties.toMutableMap() + } + + /** The Credit Block resource models prepaid credits within Orb. */ + fun block(block: Block) = block(JsonField.of(block)) + + /** + * Sets [Builder.block] to an arbitrary JSON value. + * + * You should usually call [Builder.block] with a well-typed [Block] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun block(block: JsonField) = apply { this.block = block } + + fun invoices(invoices: List) = invoices(JsonField.of(invoices)) + + /** + * Sets [Builder.invoices] to an arbitrary JSON value. + * + * You should usually call [Builder.invoices] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoices(invoices: JsonField>) = apply { + this.invoices = invoices.map { it.toMutableList() } + } + + /** + * Adds a single [Invoice] to [invoices]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInvoice(invoice: Invoice) = apply { + invoices = + (invoices ?: JsonField.of(mutableListOf())).also { + checkKnown("invoices", it).add(invoice) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreditBlockListInvoicesResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .block() + * .invoices() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditBlockListInvoicesResponse = + CreditBlockListInvoicesResponse( + checkRequired("block", block), + checkRequired("invoices", invoices).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): CreditBlockListInvoicesResponse = apply { + if (validated) { + return@apply + } + + block().validate() + invoices().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (block.asKnown().getOrNull()?.validity() ?: 0) + + (invoices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** The Credit Block resource models prepaid credits within Orb. */ + class Block + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val balance: JsonField, + private val effectiveDate: JsonField, + private val expiryDate: JsonField, + private val filters: JsonField>, + private val maximumInitialBalance: JsonField, + private val metadata: JsonField, + private val perUnitCostBasis: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("balance") @ExcludeMissing balance: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_initial_balance") + @ExcludeMissing + maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + perUnitCostBasis: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this( + id, + balance, + effectiveDate, + expiryDate, + filters, + maximumInitialBalance, + metadata, + perUnitCostBasis, + status, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun balance(): Double = balance.getRequired("balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun effectiveDate(): Optional = effectiveDate.getOptional("effective_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiryDate(): Optional = expiryDate.getOptional("expiry_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maximumInitialBalance(): Optional = + maximumInitialBalance.getOptional("maximum_initial_balance") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun perUnitCostBasis(): Optional = + perUnitCostBasis.getOptional("per_unit_cost_basis") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [balance]. + * + * Unlike [balance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [expiryDate]. + * + * Unlike [expiryDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [maximumInitialBalance]. + * + * Unlike [maximumInitialBalance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_initial_balance") + @ExcludeMissing + fun _maximumInitialBalance(): JsonField = maximumInitialBalance + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [perUnitCostBasis]. + * + * Unlike [perUnitCostBasis], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Block]. + * + * The following fields are required: + * ```java + * .id() + * .balance() + * .effectiveDate() + * .expiryDate() + * .filters() + * .maximumInitialBalance() + * .metadata() + * .perUnitCostBasis() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Block]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var balance: JsonField? = null + private var effectiveDate: JsonField? = null + private var expiryDate: JsonField? = null + private var filters: JsonField>? = null + private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(block: Block) = apply { + id = block.id + balance = block.balance + effectiveDate = block.effectiveDate + expiryDate = block.expiryDate + filters = block.filters.map { it.toMutableList() } + maximumInitialBalance = block.maximumInitialBalance + metadata = block.metadata + perUnitCostBasis = block.perUnitCostBasis + status = block.status + additionalProperties = block.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun balance(balance: Double) = balance(JsonField.of(balance)) + + /** + * Sets [Builder.balance] to an arbitrary JSON value. + * + * You should usually call [Builder.balance] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun balance(balance: JsonField) = apply { this.balance = balance } + + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + /** Alias for calling [Builder.effectiveDate] with `effectiveDate.orElse(null)`. */ + fun effectiveDate(effectiveDate: Optional) = + effectiveDate(effectiveDate.getOrNull()) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + /** Alias for calling [Builder.expiryDate] with `expiryDate.orElse(null)`. */ + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.getOrNull()) + + /** + * Sets [Builder.expiryDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + fun maximumInitialBalance(maximumInitialBalance: Double?) = + maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) + + /** + * Alias for [Builder.maximumInitialBalance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maximumInitialBalance(maximumInitialBalance: Double) = + maximumInitialBalance(maximumInitialBalance as Double?) + + /** + * Alias for calling [Builder.maximumInitialBalance] with + * `maximumInitialBalance.orElse(null)`. + */ + fun maximumInitialBalance(maximumInitialBalance: Optional) = + maximumInitialBalance(maximumInitialBalance.getOrNull()) + + /** + * Sets [Builder.maximumInitialBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumInitialBalance] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maximumInitialBalance(maximumInitialBalance: JsonField) = apply { + this.maximumInitialBalance = maximumInitialBalance + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + /** + * Alias for calling [Builder.perUnitCostBasis] with `perUnitCostBasis.orElse(null)`. + */ + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.getOrNull()) + + /** + * Sets [Builder.perUnitCostBasis] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitCostBasis] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + this.perUnitCostBasis = perUnitCostBasis + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Block]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .balance() + * .effectiveDate() + * .expiryDate() + * .filters() + * .maximumInitialBalance() + * .metadata() + * .perUnitCostBasis() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Block = + Block( + checkRequired("id", id), + checkRequired("balance", balance), + checkRequired("effectiveDate", effectiveDate), + checkRequired("expiryDate", expiryDate), + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), + checkRequired("perUnitCostBasis", perUnitCostBasis), + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Block = apply { + if (validated) { + return@apply + } + + id() + balance() + effectiveDate() + expiryDate() + filters().forEach { it.validate() } + maximumInitialBalance() + metadata().validate() + perUnitCostBasis() + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (balance.asKnown().isPresent) 1 else 0) + + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (if (expiryDate.asKnown().isPresent) 1 else 0) + + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + field = filter.field + operator = filter.operator + values = filter.values.map { it.toMutableList() } + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PRICE_ID = of("price_id") + + @JvmField val ITEM_ID = of("item_id") + + @JvmField val PRICE_TYPE = of("price_type") + + @JvmField val CURRENCY = of("currency") + + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INCLUDES = of("includes") + + @JvmField val EXCLUDES = of("excludes") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val PENDING_PAYMENT = of("pending_payment") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PENDING_PAYMENT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + PENDING_PAYMENT, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + PENDING_PAYMENT -> Value.PENDING_PAYMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PENDING_PAYMENT -> Known.PENDING_PAYMENT + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Block && + id == other.id && + balance == other.balance && + effectiveDate == other.effectiveDate && + expiryDate == other.expiryDate && + filters == other.filters && + maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && + perUnitCostBasis == other.perUnitCostBasis && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + balance, + effectiveDate, + expiryDate, + filters, + maximumInitialBalance, + metadata, + perUnitCostBasis, + status, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Block{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + } + + class Invoice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val customer: JsonField, + private val invoiceNumber: JsonField, + private val status: JsonField, + private val subscription: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("invoice_number") + @ExcludeMissing + invoiceNumber: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + ) : this(id, customer, invoiceNumber, status, subscription, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customer(): CustomerMinified = customer.getRequired("customer") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceNumber(): String = invoiceNumber.getRequired("invoice_number") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun subscription(): Optional = + subscription.getOptional("subscription") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [invoiceNumber]. + * + * Unlike [invoiceNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .id() + * .customer() + * .invoiceNumber() + * .status() + * .subscription() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Invoice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var customer: JsonField? = null + private var invoiceNumber: JsonField? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoice: Invoice) = apply { + id = invoice.id + customer = invoice.customer + invoiceNumber = invoice.invoiceNumber + status = invoice.status + subscription = invoice.subscription + additionalProperties = invoice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun customer(customer: CustomerMinified) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [CustomerMinified] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + fun invoiceNumber(invoiceNumber: String) = invoiceNumber(JsonField.of(invoiceNumber)) + + /** + * Sets [Builder.invoiceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceNumber(invoiceNumber: JsonField) = apply { + this.invoiceNumber = invoiceNumber + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: SubscriptionMinified?) = + subscription(JsonField.ofNullable(subscription)) + + /** Alias for calling [Builder.subscription] with `subscription.orElse(null)`. */ + fun subscription(subscription: Optional) = + subscription(subscription.getOrNull()) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed + * [SubscriptionMinified] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Invoice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .customer() + * .invoiceNumber() + * .status() + * .subscription() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Invoice = + Invoice( + checkRequired("id", id), + checkRequired("customer", customer), + checkRequired("invoiceNumber", invoiceNumber), + checkRequired("status", status), + checkRequired("subscription", subscription), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Invoice = apply { + if (validated) { + return@apply + } + + id() + customer().validate() + invoiceNumber() + status().validate() + subscription().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceNumber.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ISSUED = of("issued") + + @JvmField val PAID = of("paid") + + @JvmField val SYNCED = of("synced") + + @JvmField val VOID = of("void") + + @JvmField val DRAFT = of("draft") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ISSUED -> Value.ISSUED + PAID -> Value.PAID + SYNCED -> Value.SYNCED + VOID -> Value.VOID + DRAFT -> Value.DRAFT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ISSUED -> Known.ISSUED + PAID -> Known.PAID + SYNCED -> Known.SYNCED + VOID -> Known.VOID + DRAFT -> Known.DRAFT + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Invoice && + id == other.id && + customer == other.customer && + invoiceNumber == other.invoiceNumber && + status == other.status && + subscription == other.subscription && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, customer, invoiceNumber, status, subscription, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Invoice{id=$id, customer=$customer, invoiceNumber=$invoiceNumber, status=$status, subscription=$subscription, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditBlockListInvoicesResponse && + block == other.block && + invoices == other.invoices && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(block, invoices, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditBlockListInvoicesResponse{block=$block, invoices=$invoices, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt index bbc248c0e..0f64bf00b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditBlockRetrieveResponse.kt @@ -31,6 +31,7 @@ private constructor( private val expiryDate: JsonField, private val filters: JsonField>, private val maximumInitialBalance: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -52,6 +53,7 @@ private constructor( @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -63,6 +65,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, mutableMapOf(), @@ -105,6 +108,16 @@ private constructor( fun maximumInitialBalance(): Optional = maximumInitialBalance.getOptional("maximum_initial_balance") + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -166,6 +179,13 @@ private constructor( @ExcludeMissing fun _maximumInitialBalance(): JsonField = maximumInitialBalance + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -208,6 +228,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -224,6 +245,7 @@ private constructor( private var expiryDate: JsonField? = null private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -236,6 +258,7 @@ private constructor( expiryDate = creditBlockRetrieveResponse.expiryDate filters = creditBlockRetrieveResponse.filters.map { it.toMutableList() } maximumInitialBalance = creditBlockRetrieveResponse.maximumInitialBalance + metadata = creditBlockRetrieveResponse.metadata perUnitCostBasis = creditBlockRetrieveResponse.perUnitCostBasis status = creditBlockRetrieveResponse.status additionalProperties = creditBlockRetrieveResponse.additionalProperties.toMutableMap() @@ -349,6 +372,22 @@ private constructor( this.maximumInitialBalance = maximumInitialBalance } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun perUnitCostBasis(perUnitCostBasis: String?) = perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) @@ -409,6 +448,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -423,6 +463,7 @@ private constructor( checkRequired("expiryDate", expiryDate), checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), additionalProperties.toMutableMap(), @@ -431,6 +472,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CreditBlockRetrieveResponse = apply { if (validated) { return@apply @@ -442,6 +491,7 @@ private constructor( expiryDate() filters().forEach { it.validate() } maximumInitialBalance() + metadata().validate() perUnitCostBasis() status().validate() validated = true @@ -468,6 +518,7 @@ private constructor( (if (expiryDate.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) @@ -673,6 +724,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -812,6 +872,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -941,6 +1011,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -1001,6 +1081,119 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1087,6 +1280,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -1137,6 +1339,7 @@ private constructor( expiryDate == other.expiryDate && filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties @@ -1150,6 +1353,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, additionalProperties, @@ -1159,5 +1363,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CreditBlockRetrieveResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CreditBlockRetrieveResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt index b672de48e..4179b9fc9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt @@ -759,6 +759,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CreditNote = apply { if (validated) { return@apply @@ -1324,6 +1332,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): LineItem = apply { if (validated) { return@apply @@ -1745,6 +1762,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Discount = apply { if (validated) { return@apply @@ -1879,6 +1906,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -2284,6 +2321,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MaximumAmountAdjustment = apply { if (validated) { return@apply @@ -2404,6 +2450,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -2591,6 +2647,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AppliesToPrice = apply { if (validated) { return@apply @@ -2767,6 +2833,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Reason = apply { if (validated) { return@apply @@ -2891,6 +2966,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply @@ -3219,6 +3303,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Discount = apply { if (validated) { return@apply @@ -3339,6 +3432,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -3526,6 +3629,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AppliesToPrice = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt index 5a9e4b4bf..316c855ea 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt @@ -704,6 +704,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1013,6 +1022,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): LineItem = apply { if (validated) { return@apply @@ -1168,6 +1186,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Reason = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt index b386ac9f0..a73a5dec9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageResponse.kt @@ -185,6 +185,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CreditNoteListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt index ae490e890..bae02cc2c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteTiny.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CreditNoteTiny = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt index 3b4decd0b..977378b9b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomExpiration.kt @@ -166,6 +166,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomExpiration = apply { if (validated) { return@apply @@ -283,6 +291,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DurationUnit = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt index 856fcb04e..d9a3103f7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -359,11 +359,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -375,6 +377,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -405,9 +408,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -425,6 +430,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -1199,11 +1205,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1215,6 +1223,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1245,9 +1254,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1265,6 +1276,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -1501,6 +1513,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Customer = apply { if (validated) { return@apply @@ -1743,6 +1763,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Hierarchy = apply { if (validated) { return@apply @@ -1854,6 +1883,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1924,6 +1962,8 @@ private constructor( @JvmField val NETSUITE = of("netsuite") + @JvmField val NETSUITE_AMPERSAND = of("netsuite_ampersand") + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) } @@ -1934,6 +1974,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, } /** @@ -1951,6 +1992,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, /** * An enum member indicating that [PaymentProvider] was instantiated with an unknown * value. @@ -1972,6 +2014,7 @@ private constructor( STRIPE_CHARGE -> Value.STRIPE_CHARGE STRIPE_INVOICE -> Value.STRIPE_INVOICE NETSUITE -> Value.NETSUITE + NETSUITE_AMPERSAND -> Value.NETSUITE_AMPERSAND else -> Value._UNKNOWN } @@ -1990,6 +2033,7 @@ private constructor( STRIPE_CHARGE -> Known.STRIPE_CHARGE STRIPE_INVOICE -> Known.STRIPE_INVOICE NETSUITE -> Known.NETSUITE + NETSUITE_AMPERSAND -> Known.NETSUITE_AMPERSAND else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") } @@ -2007,6 +2051,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply @@ -2218,6 +2271,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AccountingSyncConfiguration = apply { if (validated) { return@apply @@ -2419,6 +2481,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AccountingProvider = apply { if (validated) { return@apply @@ -2543,6 +2615,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ProviderType = apply { if (validated) { return@apply @@ -2750,6 +2832,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentConfiguration = apply { if (validated) { return@apply @@ -2781,6 +2872,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerType: JsonField, + private val defaultSharedPaymentToken: JsonField, private val excludedPaymentMethodTypes: JsonField>, private val additionalProperties: MutableMap, ) { @@ -2790,10 +2882,18 @@ private constructor( @JsonProperty("provider_type") @ExcludeMissing providerType: JsonField = JsonMissing.of(), + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + defaultSharedPaymentToken: JsonField = JsonMissing.of(), @JsonProperty("excluded_payment_method_types") @ExcludeMissing excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), - ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + ) : this( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + mutableMapOf(), + ) /** * The payment provider to configure. @@ -2804,6 +2904,17 @@ private constructor( */ fun providerType(): ProviderType = providerType.getRequired("provider_type") + /** + * The ID of a shared payment token granted by an agent to use as the default payment + * instrument for this customer. When set, auto-collection will use this token instead + * of the customer's default payment method. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultSharedPaymentToken(): Optional = + defaultSharedPaymentToken.getOptional("default_shared_payment_token") + /** * List of Stripe payment method types to exclude for this customer. Excluded payment * methods will not be available for the customer to select during payment, and will not @@ -2827,6 +2938,16 @@ private constructor( @ExcludeMissing fun _providerType(): JsonField = providerType + /** + * Returns the raw JSON value of [defaultSharedPaymentToken]. + * + * Unlike [defaultSharedPaymentToken], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + fun _defaultSharedPaymentToken(): JsonField = defaultSharedPaymentToken + /** * Returns the raw JSON value of [excludedPaymentMethodTypes]. * @@ -2866,12 +2987,14 @@ private constructor( class Builder internal constructor() { private var providerType: JsonField? = null + private var defaultSharedPaymentToken: JsonField = JsonMissing.of() private var excludedPaymentMethodTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(paymentProvider: PaymentProvider) = apply { providerType = paymentProvider.providerType + defaultSharedPaymentToken = paymentProvider.defaultSharedPaymentToken excludedPaymentMethodTypes = paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } additionalProperties = paymentProvider.additionalProperties.toMutableMap() @@ -2892,6 +3015,33 @@ private constructor( this.providerType = providerType } + /** + * The ID of a shared payment token granted by an agent to use as the default + * payment instrument for this customer. When set, auto-collection will use this + * token instead of the customer's default payment method. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: String?) = + defaultSharedPaymentToken(JsonField.ofNullable(defaultSharedPaymentToken)) + + /** + * Alias for calling [Builder.defaultSharedPaymentToken] with + * `defaultSharedPaymentToken.orElse(null)`. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: Optional) = + defaultSharedPaymentToken(defaultSharedPaymentToken.getOrNull()) + + /** + * Sets [Builder.defaultSharedPaymentToken] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSharedPaymentToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: JsonField) = + apply { + this.defaultSharedPaymentToken = defaultSharedPaymentToken + } + /** * List of Stripe payment method types to exclude for this customer. Excluded * payment methods will not be available for the customer to select during payment, @@ -2966,6 +3116,7 @@ private constructor( fun build(): PaymentProvider = PaymentProvider( checkRequired("providerType", providerType), + defaultSharedPaymentToken, (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -2973,12 +3124,23 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply } providerType().validate() + defaultSharedPaymentToken() excludedPaymentMethodTypes() validated = true } @@ -3000,6 +3162,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (providerType.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultSharedPaymentToken.asKnown().isPresent) 1 else 0) + (excludedPaymentMethodTypes.asKnown().getOrNull()?.size ?: 0) /** The payment provider to configure. */ @@ -3092,6 +3255,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ProviderType = apply { if (validated) { return@apply @@ -3137,18 +3310,24 @@ private constructor( return other is PaymentProvider && providerType == other.providerType && + defaultSharedPaymentToken == other.defaultSharedPaymentToken && excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + Objects.hash( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + "PaymentProvider{providerType=$providerType, defaultSharedPaymentToken=$defaultSharedPaymentToken, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -3282,6 +3461,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ReportingConfiguration = apply { if (validated) { return@apply 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 57f6754d8..ad196e6bc 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 @@ -507,6 +507,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -646,6 +655,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt index 0d9525797..2b936907f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt @@ -482,6 +482,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerBalanceTransactionCreateResponse = apply { if (validated) { return@apply @@ -660,6 +668,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Action = apply { if (validated) { return@apply @@ -784,6 +801,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt index 650f4c7a0..8aab97310 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageResponse.kt @@ -193,6 +193,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerBalanceTransactionListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt index c265e6ed5..6ef1f8433 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt @@ -482,6 +482,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerBalanceTransactionListResponse = apply { if (validated) { return@apply @@ -660,6 +668,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Action = apply { if (validated) { return@apply @@ -784,6 +801,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply 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 d9318231e..3558c38d0 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 @@ -460,6 +460,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ViewMode = apply { if (validated) { return@apply 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 86d9cce3a..8f0b17259 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 @@ -151,6 +151,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCostListByExternalIdResponse = apply { if (validated) { return@apply 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 729730f4e..ca95996dd 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 @@ -450,6 +450,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ViewMode = apply { if (validated) { return@apply 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 40d19b190..1693dce00 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 @@ -147,6 +147,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCostListResponse = apply { if (validated) { return@apply 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 702f26ece..25a4d8a0f 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 @@ -259,11 +259,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -275,6 +277,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -305,9 +308,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -325,6 +330,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -1118,11 +1124,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1134,6 +1142,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1164,9 +1173,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1184,6 +1195,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -1703,11 +1715,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1719,6 +1733,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1749,9 +1764,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1769,6 +1786,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -2637,11 +2655,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -2653,6 +2673,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -2683,9 +2704,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -2703,6 +2726,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -2818,6 +2842,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -3007,6 +3040,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -3175,6 +3217,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentConfiguration = apply { if (validated) { return@apply @@ -3206,6 +3257,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerType: JsonField, + private val defaultSharedPaymentToken: JsonField, private val excludedPaymentMethodTypes: JsonField>, private val additionalProperties: MutableMap, ) { @@ -3215,10 +3267,18 @@ private constructor( @JsonProperty("provider_type") @ExcludeMissing providerType: JsonField = JsonMissing.of(), + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + defaultSharedPaymentToken: JsonField = JsonMissing.of(), @JsonProperty("excluded_payment_method_types") @ExcludeMissing excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), - ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + ) : this( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + mutableMapOf(), + ) /** * The payment provider to configure. @@ -3229,6 +3289,17 @@ private constructor( */ fun providerType(): ProviderType = providerType.getRequired("provider_type") + /** + * The ID of a shared payment token granted by an agent to use as the default payment + * instrument for this customer. When set, auto-collection will use this token instead + * of the customer's default payment method. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultSharedPaymentToken(): Optional = + defaultSharedPaymentToken.getOptional("default_shared_payment_token") + /** * List of Stripe payment method types to exclude for this customer. Excluded payment * methods will not be available for the customer to select during payment, and will not @@ -3252,6 +3323,16 @@ private constructor( @ExcludeMissing fun _providerType(): JsonField = providerType + /** + * Returns the raw JSON value of [defaultSharedPaymentToken]. + * + * Unlike [defaultSharedPaymentToken], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + fun _defaultSharedPaymentToken(): JsonField = defaultSharedPaymentToken + /** * Returns the raw JSON value of [excludedPaymentMethodTypes]. * @@ -3291,12 +3372,14 @@ private constructor( class Builder internal constructor() { private var providerType: JsonField? = null + private var defaultSharedPaymentToken: JsonField = JsonMissing.of() private var excludedPaymentMethodTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(paymentProvider: PaymentProvider) = apply { providerType = paymentProvider.providerType + defaultSharedPaymentToken = paymentProvider.defaultSharedPaymentToken excludedPaymentMethodTypes = paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } additionalProperties = paymentProvider.additionalProperties.toMutableMap() @@ -3317,6 +3400,33 @@ private constructor( this.providerType = providerType } + /** + * The ID of a shared payment token granted by an agent to use as the default + * payment instrument for this customer. When set, auto-collection will use this + * token instead of the customer's default payment method. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: String?) = + defaultSharedPaymentToken(JsonField.ofNullable(defaultSharedPaymentToken)) + + /** + * Alias for calling [Builder.defaultSharedPaymentToken] with + * `defaultSharedPaymentToken.orElse(null)`. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: Optional) = + defaultSharedPaymentToken(defaultSharedPaymentToken.getOrNull()) + + /** + * Sets [Builder.defaultSharedPaymentToken] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSharedPaymentToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: JsonField) = + apply { + this.defaultSharedPaymentToken = defaultSharedPaymentToken + } + /** * List of Stripe payment method types to exclude for this customer. Excluded * payment methods will not be available for the customer to select during payment, @@ -3391,6 +3501,7 @@ private constructor( fun build(): PaymentProvider = PaymentProvider( checkRequired("providerType", providerType), + defaultSharedPaymentToken, (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -3398,12 +3509,23 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply } providerType().validate() + defaultSharedPaymentToken() excludedPaymentMethodTypes() validated = true } @@ -3425,6 +3547,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (providerType.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultSharedPaymentToken.asKnown().isPresent) 1 else 0) + (excludedPaymentMethodTypes.asKnown().getOrNull()?.size ?: 0) /** The payment provider to configure. */ @@ -3517,6 +3640,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ProviderType = apply { if (validated) { return@apply @@ -3562,18 +3695,24 @@ private constructor( return other is PaymentProvider && providerType == other.providerType && + defaultSharedPaymentToken == other.defaultSharedPaymentToken && excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + Objects.hash( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + "PaymentProvider{providerType=$providerType, defaultSharedPaymentToken=$defaultSharedPaymentToken, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -3623,6 +3762,8 @@ private constructor( @JvmField val NETSUITE = of("netsuite") + @JvmField val NETSUITE_AMPERSAND = of("netsuite_ampersand") + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) } @@ -3633,6 +3774,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, } /** @@ -3650,6 +3792,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, /** * An enum member indicating that [PaymentProvider] was instantiated with an unknown * value. @@ -3671,6 +3814,7 @@ private constructor( STRIPE_CHARGE -> Value.STRIPE_CHARGE STRIPE_INVOICE -> Value.STRIPE_INVOICE NETSUITE -> Value.NETSUITE + NETSUITE_AMPERSAND -> Value.NETSUITE_AMPERSAND else -> Value._UNKNOWN } @@ -3689,6 +3833,7 @@ private constructor( STRIPE_CHARGE -> Known.STRIPE_CHARGE STRIPE_INVOICE -> Known.STRIPE_INVOICE NETSUITE -> Known.NETSUITE + NETSUITE_AMPERSAND -> Known.NETSUITE_AMPERSAND else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") } @@ -3706,6 +3851,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply @@ -3795,6 +3949,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = taxConfiguration.accept(new TaxConfiguration.Visitor>() { + * @Override + * public Optional visitAvalara(NewAvalaraTaxConfiguration avalara) { + * return Optional.of(avalara.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { avalara != null -> visitor.visitAvalara(avalara) @@ -3808,6 +3991,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TaxConfiguration = apply { if (validated) { return@apply @@ -4237,6 +4429,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Numeral = apply { if (validated) { return@apply @@ -4510,6 +4712,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Anrok = apply { if (validated) { return@apply @@ -4783,6 +4995,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Stripe = apply { if (validated) { return@apply 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 db2e67796..5e4fe296e 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 @@ -78,14 +78,27 @@ import kotlin.jvm.optionals.getOrNull * pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for * the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying the - * cost basis with the number of credit units added. + * cost basis with the number of credit units added. If you invoice or handle payment of credits + * outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the `invoice_settings` to + * `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required to + * determine the due date * * ## Deducting Credits - * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb - * matches the algorithm for automatic deductions for determining which credit blocks to decrement - * from. In the case that the deduction leads to multiple ledger entries, the response from this - * endpoint will be the final deduction. Orb also optionally allows specifying a description to - * assist with auditing. + * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. A + * `decrement` entry records credits as usage and immediately recognizes revenue at the block's + * `per_unit_cost_basis`. + * + * For most credit removals, use `void` (no revenue impact) or `expiration_change` (revenue + * recognized on expiration) instead. Only use `decrement` when credits were genuinely consumed + * outside of normal event ingestion. + * + * Orb matches the algorithm for automatic deductions for determining which credit blocks to + * decrement from. In the case that the deduction leads to multiple ledger entries, the response + * from this endpoint will be the final deduction. Orb also optionally allows specifying a + * description to assist with auditing. * * The following snippet illustrates a sample request body to decrement credits. * @@ -424,6 +437,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = body.accept(new Body.Visitor>() { + * @Override + * public Optional visitIncrement(Increment increment) { + * return Optional.of(increment.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { increment != null -> visitor.visitIncrement(increment) @@ -436,6 +478,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1188,6 +1239,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Increment = apply { if (validated) { return@apply @@ -1457,6 +1518,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1577,6 +1648,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1713,6 +1794,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -1786,6 +1877,7 @@ private constructor( private val customDueDate: JsonField, private val invoiceDate: JsonField, private val itemId: JsonField, + private val markAsPaid: JsonField, private val memo: JsonField, private val netTerms: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1806,6 +1898,9 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("mark_as_paid") + @ExcludeMissing + markAsPaid: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), @@ -1820,6 +1915,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -1865,6 +1961,14 @@ private constructor( */ fun itemId(): Optional = itemId.getOptional("item_id") + /** + * If true, the new credits purchase invoice will be marked as paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun markAsPaid(): Optional = markAsPaid.getOptional("mark_as_paid") + /** * An optional memo to display on the invoice. * @@ -1878,7 +1982,7 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured due * date calculation method. A value of '0' here represents that the invoice is due * on issue, whereas a value of '30' represents that the customer has 30 days to pay - * the invoice. Do not set this field if you want to set a custom due date. + * the invoice. You must set either `net_terms` or `custom_due_date`, but not both. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1933,6 +2037,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [markAsPaid]. + * + * Unlike [markAsPaid], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mark_as_paid") + @ExcludeMissing + fun _markAsPaid(): JsonField = markAsPaid + /** * Returns the raw JSON value of [memo]. * @@ -1993,6 +2107,7 @@ private constructor( private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var itemId: JsonField = JsonMissing.of() + private var markAsPaid: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var netTerms: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() @@ -2004,6 +2119,7 @@ private constructor( customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate itemId = invoiceSettings.itemId + markAsPaid = invoiceSettings.markAsPaid memo = invoiceSettings.memo netTerms = invoiceSettings.netTerms requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment @@ -2109,6 +2225,20 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** If true, the new credits purchase invoice will be marked as paid. */ + fun markAsPaid(markAsPaid: Boolean) = markAsPaid(JsonField.of(markAsPaid)) + + /** + * Sets [Builder.markAsPaid] to an arbitrary JSON value. + * + * You should usually call [Builder.markAsPaid] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun markAsPaid(markAsPaid: JsonField) = apply { + this.markAsPaid = markAsPaid + } + /** An optional memo to display on the invoice. */ fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) @@ -2129,8 +2259,8 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured * due date calculation method. A value of '0' here represents that the invoice * is due on issue, whereas a value of '30' represents that the customer has 30 - * days to pay the invoice. Do not set this field if you want to set a custom - * due date. + * days to pay the invoice. You must set either `net_terms` or + * `custom_due_date`, but not both. */ fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) @@ -2212,6 +2342,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2221,6 +2352,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): InvoiceSettings = apply { if (validated) { return@apply @@ -2230,6 +2371,7 @@ private constructor( customDueDate().ifPresent { it.validate() } invoiceDate().ifPresent { it.validate() } itemId() + markAsPaid() memo() netTerms() requireSuccessfulPayment() @@ -2256,6 +2398,7 @@ private constructor( (customDueDate.asKnown().getOrNull()?.validity() ?: 0) + (invoiceDate.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (markAsPaid.asKnown().isPresent) 1 else 0) + (if (memo.asKnown().isPresent) 1 else 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) @@ -2287,6 +2430,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not + * known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = customDueDate.accept(new CustomDueDate.Visitor>() { + * @Override + * public Optional visitDate(LocalDate date) { + * return Optional.of(date.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { date != null -> visitor.visitDate(date) @@ -2296,6 +2470,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): CustomDueDate = apply { if (validated) { return@apply @@ -2469,6 +2653,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not + * known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = invoiceDate.accept(new InvoiceDate.Visitor>() { + * @Override + * public Optional visitDate(LocalDate date) { + * return Optional.of(date.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { date != null -> visitor.visitDate(date) @@ -2478,6 +2693,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): InvoiceDate = apply { if (validated) { return@apply @@ -2631,6 +2856,7 @@ private constructor( customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && itemId == other.itemId && + markAsPaid == other.markAsPaid && memo == other.memo && netTerms == other.netTerms && requireSuccessfulPayment == other.requireSuccessfulPayment && @@ -2643,6 +2869,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2653,7 +2880,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, markAsPaid=$markAsPaid, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** @@ -2722,6 +2949,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -3100,6 +3337,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Decrement = apply { if (validated) { return@apply @@ -3205,6 +3452,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -3341,8 +3598,9 @@ private constructor( @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** - * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting - * when credits transferred (as part of a partial block expiration) should expire. + * A date (specified in YYYY-MM-DD format) used for expiration change, denoting when + * credits transferred (as part of a partial block expiration) should expire. This date + * must be on or after the effective date of the credit block. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -3533,9 +3791,9 @@ private constructor( fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** - * A future date (specified in YYYY-MM-DD format) used for expiration change, - * denoting when credits transferred (as part of a partial block expiration) should - * expire. + * A date (specified in YYYY-MM-DD format) used for expiration change, denoting when + * credits transferred (as part of a partial block expiration) should expire. This + * date must be on or after the effective date of the credit block. */ fun targetExpiryDate(targetExpiryDate: LocalDate) = targetExpiryDate(JsonField.of(targetExpiryDate)) @@ -3725,6 +3983,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExpirationChange = apply { if (validated) { return@apply @@ -3836,6 +4104,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -4300,6 +4578,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Void = apply { if (validated) { return@apply @@ -4409,6 +4697,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -4541,6 +4839,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): VoidReason = apply { if (validated) { return@apply @@ -4945,6 +5253,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Amendment = apply { if (validated) { return@apply @@ -5052,6 +5370,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply 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 b82770619..2fae56095 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 @@ -84,6 +84,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = customerCreditLedgerCreateEntryByExternalIdResponse.accept(new CustomerCreditLedgerCreateEntryByExternalIdResponse.Visitor>() { + * @Override + * public Optional visitIncrement(IncrementLedgerEntry increment) { + * return Optional.of(increment.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and the + * current variant is unknown. + */ fun accept(visitor: Visitor): T = when { increment != null -> visitor.visitIncrement(increment) @@ -98,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditLedgerCreateEntryByExternalIdResponse = apply { if (validated) { return@apply 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 9b94f9852..56c71ea54 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 @@ -78,14 +78,27 @@ import kotlin.jvm.optionals.getOrNull * pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for * the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying the - * cost basis with the number of credit units added. + * cost basis with the number of credit units added. If you invoice or handle payment of credits + * outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the `invoice_settings` to + * `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required to + * determine the due date * * ## Deducting Credits - * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb - * matches the algorithm for automatic deductions for determining which credit blocks to decrement - * from. In the case that the deduction leads to multiple ledger entries, the response from this - * endpoint will be the final deduction. Orb also optionally allows specifying a description to - * assist with auditing. + * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. A + * `decrement` entry records credits as usage and immediately recognizes revenue at the block's + * `per_unit_cost_basis`. + * + * For most credit removals, use `void` (no revenue impact) or `expiration_change` (revenue + * recognized on expiration) instead. Only use `decrement` when credits were genuinely consumed + * outside of normal event ingestion. + * + * Orb matches the algorithm for automatic deductions for determining which credit blocks to + * decrement from. In the case that the deduction leads to multiple ledger entries, the response + * from this endpoint will be the final deduction. Orb also optionally allows specifying a + * description to assist with auditing. * * The following snippet illustrates a sample request body to decrement credits. * @@ -416,6 +429,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = body.accept(new Body.Visitor>() { + * @Override + * public Optional visitIncrement(Increment increment) { + * return Optional.of(increment.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { increment != null -> visitor.visitIncrement(increment) @@ -428,6 +470,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1180,6 +1231,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Increment = apply { if (validated) { return@apply @@ -1449,6 +1510,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1569,6 +1640,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1705,6 +1786,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -1778,6 +1869,7 @@ private constructor( private val customDueDate: JsonField, private val invoiceDate: JsonField, private val itemId: JsonField, + private val markAsPaid: JsonField, private val memo: JsonField, private val netTerms: JsonField, private val requireSuccessfulPayment: JsonField, @@ -1798,6 +1890,9 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("mark_as_paid") + @ExcludeMissing + markAsPaid: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), @@ -1812,6 +1907,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -1857,6 +1953,14 @@ private constructor( */ fun itemId(): Optional = itemId.getOptional("item_id") + /** + * If true, the new credits purchase invoice will be marked as paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun markAsPaid(): Optional = markAsPaid.getOptional("mark_as_paid") + /** * An optional memo to display on the invoice. * @@ -1870,7 +1974,7 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured due * date calculation method. A value of '0' here represents that the invoice is due * on issue, whereas a value of '30' represents that the customer has 30 days to pay - * the invoice. Do not set this field if you want to set a custom due date. + * the invoice. You must set either `net_terms` or `custom_due_date`, but not both. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1925,6 +2029,16 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [markAsPaid]. + * + * Unlike [markAsPaid], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mark_as_paid") + @ExcludeMissing + fun _markAsPaid(): JsonField = markAsPaid + /** * Returns the raw JSON value of [memo]. * @@ -1985,6 +2099,7 @@ private constructor( private var customDueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var itemId: JsonField = JsonMissing.of() + private var markAsPaid: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var netTerms: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() @@ -1996,6 +2111,7 @@ private constructor( customDueDate = invoiceSettings.customDueDate invoiceDate = invoiceSettings.invoiceDate itemId = invoiceSettings.itemId + markAsPaid = invoiceSettings.markAsPaid memo = invoiceSettings.memo netTerms = invoiceSettings.netTerms requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment @@ -2101,6 +2217,20 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** If true, the new credits purchase invoice will be marked as paid. */ + fun markAsPaid(markAsPaid: Boolean) = markAsPaid(JsonField.of(markAsPaid)) + + /** + * Sets [Builder.markAsPaid] to an arbitrary JSON value. + * + * You should usually call [Builder.markAsPaid] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun markAsPaid(markAsPaid: JsonField) = apply { + this.markAsPaid = markAsPaid + } + /** An optional memo to display on the invoice. */ fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) @@ -2121,8 +2251,8 @@ private constructor( * based on the invoice or issuance date, depending on the account's configured * due date calculation method. A value of '0' here represents that the invoice * is due on issue, whereas a value of '30' represents that the customer has 30 - * days to pay the invoice. Do not set this field if you want to set a custom - * due date. + * days to pay the invoice. You must set either `net_terms` or + * `custom_due_date`, but not both. */ fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) @@ -2204,6 +2334,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2213,6 +2344,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): InvoiceSettings = apply { if (validated) { return@apply @@ -2222,6 +2363,7 @@ private constructor( customDueDate().ifPresent { it.validate() } invoiceDate().ifPresent { it.validate() } itemId() + markAsPaid() memo() netTerms() requireSuccessfulPayment() @@ -2248,6 +2390,7 @@ private constructor( (customDueDate.asKnown().getOrNull()?.validity() ?: 0) + (invoiceDate.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (markAsPaid.asKnown().isPresent) 1 else 0) + (if (memo.asKnown().isPresent) 1 else 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + (if (requireSuccessfulPayment.asKnown().isPresent) 1 else 0) @@ -2279,6 +2422,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not + * known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = customDueDate.accept(new CustomDueDate.Visitor>() { + * @Override + * public Optional visitDate(LocalDate date) { + * return Optional.of(date.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { date != null -> visitor.visitDate(date) @@ -2288,6 +2462,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): CustomDueDate = apply { if (validated) { return@apply @@ -2461,6 +2645,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not + * known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = invoiceDate.accept(new InvoiceDate.Visitor>() { + * @Override + * public Optional visitDate(LocalDate date) { + * return Optional.of(date.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { date != null -> visitor.visitDate(date) @@ -2470,6 +2685,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): InvoiceDate = apply { if (validated) { return@apply @@ -2623,6 +2848,7 @@ private constructor( customDueDate == other.customDueDate && invoiceDate == other.invoiceDate && itemId == other.itemId && + markAsPaid == other.markAsPaid && memo == other.memo && netTerms == other.netTerms && requireSuccessfulPayment == other.requireSuccessfulPayment && @@ -2635,6 +2861,7 @@ private constructor( customDueDate, invoiceDate, itemId, + markAsPaid, memo, netTerms, requireSuccessfulPayment, @@ -2645,7 +2872,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" + "InvoiceSettings{autoCollection=$autoCollection, customDueDate=$customDueDate, invoiceDate=$invoiceDate, itemId=$itemId, markAsPaid=$markAsPaid, memo=$memo, netTerms=$netTerms, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" } /** @@ -2714,6 +2941,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -3092,6 +3329,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Decrement = apply { if (validated) { return@apply @@ -3197,6 +3444,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -3333,8 +3590,9 @@ private constructor( @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** - * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting - * when credits transferred (as part of a partial block expiration) should expire. + * A date (specified in YYYY-MM-DD format) used for expiration change, denoting when + * credits transferred (as part of a partial block expiration) should expire. This date + * must be on or after the effective date of the credit block. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -3525,9 +3783,9 @@ private constructor( fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** - * A future date (specified in YYYY-MM-DD format) used for expiration change, - * denoting when credits transferred (as part of a partial block expiration) should - * expire. + * A date (specified in YYYY-MM-DD format) used for expiration change, denoting when + * credits transferred (as part of a partial block expiration) should expire. This + * date must be on or after the effective date of the credit block. */ fun targetExpiryDate(targetExpiryDate: LocalDate) = targetExpiryDate(JsonField.of(targetExpiryDate)) @@ -3717,6 +3975,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExpirationChange = apply { if (validated) { return@apply @@ -3828,6 +4096,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -4292,6 +4570,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Void = apply { if (validated) { return@apply @@ -4401,6 +4689,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -4533,6 +4831,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): VoidReason = apply { if (validated) { return@apply @@ -4937,6 +5245,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Amendment = apply { if (validated) { return@apply @@ -5044,6 +5362,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply 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 5bcd947d2..1fe7f682d 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 @@ -84,6 +84,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = customerCreditLedgerCreateEntryResponse.accept(new CustomerCreditLedgerCreateEntryResponse.Visitor>() { + * @Override + * public Optional visitIncrement(IncrementLedgerEntry increment) { + * return Optional.of(increment.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and the + * current variant is unknown. + */ fun accept(visitor: Visitor): T = when { increment != null -> visitor.visitIncrement(increment) @@ -98,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditLedgerCreateEntryResponse = apply { if (validated) { return@apply 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 29ac9ad89..4b1f0d88a 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 @@ -249,6 +249,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditLedgerListByExternalIdPageResponse = apply { if (validated) { return@apply 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 f60e9739a..15de8ce4e 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 @@ -38,10 +38,8 @@ import kotlin.jvm.optionals.getOrNull * * As usage for a customer is reported into Orb, credits may be deducted according to the customer's * plan configuration. An automated deduction of this type will result in a ledger entry, also with - * a starting and ending balance. In order to provide better tracing capabilities for automatic - * deductions, Orb always associates each automatic deduction with the `event_id` at the time of - * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are - * never deducted without an associated usage event. + * a starting and ending balance. Each day's usage for a particular price, invoice, and block will + * be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring credit * block* first in order to ensure that all credits are utilized appropriately. As an example, if @@ -508,6 +506,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryStatus = apply { if (validated) { return@apply @@ -664,6 +671,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryType = apply { if (validated) { return@apply 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 4d45fef8a..7ddb9fbee 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 @@ -84,6 +84,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = customerCreditLedgerListByExternalIdResponse.accept(new CustomerCreditLedgerListByExternalIdResponse.Visitor>() { + * @Override + * public Optional visitIncrement(IncrementLedgerEntry increment) { + * return Optional.of(increment.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and the + * current variant is unknown. + */ fun accept(visitor: Visitor): T = when { increment != null -> visitor.visitIncrement(increment) @@ -98,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditLedgerListByExternalIdResponse = apply { if (validated) { return@apply 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 b12e38cbc..f701a6e19 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 @@ -239,6 +239,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditLedgerListPageResponse = apply { if (validated) { return@apply 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 b6a021be9..b153128a7 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 @@ -38,10 +38,8 @@ import kotlin.jvm.optionals.getOrNull * * As usage for a customer is reported into Orb, credits may be deducted according to the customer's * plan configuration. An automated deduction of this type will result in a ledger entry, also with - * a starting and ending balance. In order to provide better tracing capabilities for automatic - * deductions, Orb always associates each automatic deduction with the `event_id` at the time of - * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are - * never deducted without an associated usage event. + * a starting and ending balance. Each day's usage for a particular price, invoice, and block will + * be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring credit * block* first in order to ensure that all credits are utilized appropriately. As an example, if @@ -499,6 +497,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryStatus = apply { if (validated) { return@apply @@ -655,6 +662,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryType = apply { if (validated) { return@apply 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 d976e82f3..45e18ceb4 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 @@ -84,6 +84,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = customerCreditLedgerListResponse.accept(new CustomerCreditLedgerListResponse.Visitor>() { + * @Override + * public Optional visitIncrement(IncrementLedgerEntry increment) { + * return Optional.of(increment.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and the + * current variant is unknown. + */ fun accept(visitor: Visitor): T = when { increment != null -> visitor.visitIncrement(increment) @@ -98,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditLedgerListResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt index 901f2f723..eb275f32e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponse.kt @@ -193,6 +193,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditListByExternalIdPageResponse = apply { if (validated) { return@apply 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 a4a0cf202..bb5177829 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 @@ -5,6 +5,8 @@ package com.withorb.api.models import com.withorb.api.core.Params import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -17,12 +19,21 @@ import kotlin.jvm.optionals.getOrNull * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ class CustomerCreditListByExternalIdParams private constructor( private val externalCustomerId: String?, private val currency: String?, private val cursor: String?, + private val effectiveDateGt: OffsetDateTime?, + private val effectiveDateGte: OffsetDateTime?, + private val effectiveDateLt: OffsetDateTime?, + private val effectiveDateLte: OffsetDateTime?, private val includeAllBlocks: Boolean?, private val limit: Long?, private val additionalHeaders: Headers, @@ -40,6 +51,14 @@ private constructor( */ fun cursor(): Optional = Optional.ofNullable(cursor) + fun effectiveDateGt(): Optional = Optional.ofNullable(effectiveDateGt) + + fun effectiveDateGte(): Optional = Optional.ofNullable(effectiveDateGte) + + fun effectiveDateLt(): Optional = Optional.ofNullable(effectiveDateLt) + + fun effectiveDateLte(): Optional = Optional.ofNullable(effectiveDateLte) + /** * If set to True, all expired and depleted blocks, as well as active block will be returned. */ @@ -73,6 +92,10 @@ private constructor( private var externalCustomerId: String? = null private var currency: String? = null private var cursor: String? = null + private var effectiveDateGt: OffsetDateTime? = null + private var effectiveDateGte: OffsetDateTime? = null + private var effectiveDateLt: OffsetDateTime? = null + private var effectiveDateLte: OffsetDateTime? = null private var includeAllBlocks: Boolean? = null private var limit: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -85,6 +108,10 @@ private constructor( externalCustomerId = customerCreditListByExternalIdParams.externalCustomerId currency = customerCreditListByExternalIdParams.currency cursor = customerCreditListByExternalIdParams.cursor + effectiveDateGt = customerCreditListByExternalIdParams.effectiveDateGt + effectiveDateGte = customerCreditListByExternalIdParams.effectiveDateGte + effectiveDateLt = customerCreditListByExternalIdParams.effectiveDateLt + effectiveDateLte = customerCreditListByExternalIdParams.effectiveDateLte includeAllBlocks = customerCreditListByExternalIdParams.includeAllBlocks limit = customerCreditListByExternalIdParams.limit additionalHeaders = customerCreditListByExternalIdParams.additionalHeaders.toBuilder() @@ -117,6 +144,38 @@ private constructor( /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + fun effectiveDateGt(effectiveDateGt: OffsetDateTime?) = apply { + this.effectiveDateGt = effectiveDateGt + } + + /** Alias for calling [Builder.effectiveDateGt] with `effectiveDateGt.orElse(null)`. */ + fun effectiveDateGt(effectiveDateGt: Optional) = + effectiveDateGt(effectiveDateGt.getOrNull()) + + fun effectiveDateGte(effectiveDateGte: OffsetDateTime?) = apply { + this.effectiveDateGte = effectiveDateGte + } + + /** Alias for calling [Builder.effectiveDateGte] with `effectiveDateGte.orElse(null)`. */ + fun effectiveDateGte(effectiveDateGte: Optional) = + effectiveDateGte(effectiveDateGte.getOrNull()) + + fun effectiveDateLt(effectiveDateLt: OffsetDateTime?) = apply { + this.effectiveDateLt = effectiveDateLt + } + + /** Alias for calling [Builder.effectiveDateLt] with `effectiveDateLt.orElse(null)`. */ + fun effectiveDateLt(effectiveDateLt: Optional) = + effectiveDateLt(effectiveDateLt.getOrNull()) + + fun effectiveDateLte(effectiveDateLte: OffsetDateTime?) = apply { + this.effectiveDateLte = effectiveDateLte + } + + /** Alias for calling [Builder.effectiveDateLte] with `effectiveDateLte.orElse(null)`. */ + fun effectiveDateLte(effectiveDateLte: Optional) = + effectiveDateLte(effectiveDateLte.getOrNull()) + /** * If set to True, all expired and depleted blocks, as well as active block will be * returned. @@ -258,6 +317,10 @@ private constructor( externalCustomerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders.build(), @@ -278,6 +341,18 @@ private constructor( .apply { currency?.let { put("currency", it) } cursor?.let { put("cursor", it) } + effectiveDateGt?.let { + put("effective_date[gt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateGte?.let { + put("effective_date[gte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLt?.let { + put("effective_date[lt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLte?.let { + put("effective_date[lte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } includeAllBlocks?.let { put("include_all_blocks", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) @@ -293,6 +368,10 @@ private constructor( externalCustomerId == other.externalCustomerId && currency == other.currency && cursor == other.cursor && + effectiveDateGt == other.effectiveDateGt && + effectiveDateGte == other.effectiveDateGte && + effectiveDateLt == other.effectiveDateLt && + effectiveDateLte == other.effectiveDateLte && includeAllBlocks == other.includeAllBlocks && limit == other.limit && additionalHeaders == other.additionalHeaders && @@ -304,6 +383,10 @@ private constructor( externalCustomerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders, @@ -311,5 +394,5 @@ private constructor( ) override fun toString() = - "CustomerCreditListByExternalIdParams{externalCustomerId=$externalCustomerId, currency=$currency, cursor=$cursor, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditListByExternalIdParams{externalCustomerId=$externalCustomerId, currency=$currency, cursor=$cursor, effectiveDateGt=$effectiveDateGt, effectiveDateGte=$effectiveDateGte, effectiveDateLt=$effectiveDateLt, effectiveDateLte=$effectiveDateLte, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index f1e619c12..ebcc0e6f0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -30,6 +30,7 @@ private constructor( private val expiryDate: JsonField, private val filters: JsonField>, private val maximumInitialBalance: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -51,6 +52,7 @@ private constructor( @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -62,6 +64,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, mutableMapOf(), @@ -104,6 +107,16 @@ private constructor( fun maximumInitialBalance(): Optional = maximumInitialBalance.getOptional("maximum_initial_balance") + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -165,6 +178,13 @@ private constructor( @ExcludeMissing fun _maximumInitialBalance(): JsonField = maximumInitialBalance + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -208,6 +228,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -224,6 +245,7 @@ private constructor( private var expiryDate: JsonField? = null private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -238,6 +260,7 @@ private constructor( expiryDate = customerCreditListByExternalIdResponse.expiryDate filters = customerCreditListByExternalIdResponse.filters.map { it.toMutableList() } maximumInitialBalance = customerCreditListByExternalIdResponse.maximumInitialBalance + metadata = customerCreditListByExternalIdResponse.metadata perUnitCostBasis = customerCreditListByExternalIdResponse.perUnitCostBasis status = customerCreditListByExternalIdResponse.status additionalProperties = @@ -352,6 +375,22 @@ private constructor( this.maximumInitialBalance = maximumInitialBalance } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun perUnitCostBasis(perUnitCostBasis: String?) = perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) @@ -412,6 +451,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -426,6 +466,7 @@ private constructor( checkRequired("expiryDate", expiryDate), checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), additionalProperties.toMutableMap(), @@ -434,6 +475,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditListByExternalIdResponse = apply { if (validated) { return@apply @@ -445,6 +494,7 @@ private constructor( expiryDate() filters().forEach { it.validate() } maximumInitialBalance() + metadata().validate() perUnitCostBasis() status().validate() validated = true @@ -471,6 +521,7 @@ private constructor( (if (expiryDate.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) @@ -677,6 +728,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -792,6 +852,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -921,6 +991,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -981,6 +1061,119 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1067,6 +1260,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -1117,6 +1319,7 @@ private constructor( expiryDate == other.expiryDate && filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties @@ -1130,6 +1333,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, additionalProperties, @@ -1139,5 +1343,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditListByExternalIdResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CustomerCreditListByExternalIdResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt index e316012eb..f3442819f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageResponse.kt @@ -191,6 +191,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditListPageResponse = apply { if (validated) { return@apply 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 1819ee0c9..06a399edf 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 @@ -5,6 +5,8 @@ package com.withorb.api.models import com.withorb.api.core.Params import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -17,12 +19,21 @@ import kotlin.jvm.optionals.getOrNull * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ class CustomerCreditListParams private constructor( private val customerId: String?, private val currency: String?, private val cursor: String?, + private val effectiveDateGt: OffsetDateTime?, + private val effectiveDateGte: OffsetDateTime?, + private val effectiveDateLt: OffsetDateTime?, + private val effectiveDateLte: OffsetDateTime?, private val includeAllBlocks: Boolean?, private val limit: Long?, private val additionalHeaders: Headers, @@ -40,6 +51,14 @@ private constructor( */ fun cursor(): Optional = Optional.ofNullable(cursor) + fun effectiveDateGt(): Optional = Optional.ofNullable(effectiveDateGt) + + fun effectiveDateGte(): Optional = Optional.ofNullable(effectiveDateGte) + + fun effectiveDateLt(): Optional = Optional.ofNullable(effectiveDateLt) + + fun effectiveDateLte(): Optional = Optional.ofNullable(effectiveDateLte) + /** * If set to True, all expired and depleted blocks, as well as active block will be returned. */ @@ -70,6 +89,10 @@ private constructor( private var customerId: String? = null private var currency: String? = null private var cursor: String? = null + private var effectiveDateGt: OffsetDateTime? = null + private var effectiveDateGte: OffsetDateTime? = null + private var effectiveDateLt: OffsetDateTime? = null + private var effectiveDateLte: OffsetDateTime? = null private var includeAllBlocks: Boolean? = null private var limit: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -80,6 +103,10 @@ private constructor( customerId = customerCreditListParams.customerId currency = customerCreditListParams.currency cursor = customerCreditListParams.cursor + effectiveDateGt = customerCreditListParams.effectiveDateGt + effectiveDateGte = customerCreditListParams.effectiveDateGte + effectiveDateLt = customerCreditListParams.effectiveDateLt + effectiveDateLte = customerCreditListParams.effectiveDateLte includeAllBlocks = customerCreditListParams.includeAllBlocks limit = customerCreditListParams.limit additionalHeaders = customerCreditListParams.additionalHeaders.toBuilder() @@ -106,6 +133,38 @@ private constructor( /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + fun effectiveDateGt(effectiveDateGt: OffsetDateTime?) = apply { + this.effectiveDateGt = effectiveDateGt + } + + /** Alias for calling [Builder.effectiveDateGt] with `effectiveDateGt.orElse(null)`. */ + fun effectiveDateGt(effectiveDateGt: Optional) = + effectiveDateGt(effectiveDateGt.getOrNull()) + + fun effectiveDateGte(effectiveDateGte: OffsetDateTime?) = apply { + this.effectiveDateGte = effectiveDateGte + } + + /** Alias for calling [Builder.effectiveDateGte] with `effectiveDateGte.orElse(null)`. */ + fun effectiveDateGte(effectiveDateGte: Optional) = + effectiveDateGte(effectiveDateGte.getOrNull()) + + fun effectiveDateLt(effectiveDateLt: OffsetDateTime?) = apply { + this.effectiveDateLt = effectiveDateLt + } + + /** Alias for calling [Builder.effectiveDateLt] with `effectiveDateLt.orElse(null)`. */ + fun effectiveDateLt(effectiveDateLt: Optional) = + effectiveDateLt(effectiveDateLt.getOrNull()) + + fun effectiveDateLte(effectiveDateLte: OffsetDateTime?) = apply { + this.effectiveDateLte = effectiveDateLte + } + + /** Alias for calling [Builder.effectiveDateLte] with `effectiveDateLte.orElse(null)`. */ + fun effectiveDateLte(effectiveDateLte: Optional) = + effectiveDateLte(effectiveDateLte.getOrNull()) + /** * If set to True, all expired and depleted blocks, as well as active block will be * returned. @@ -247,6 +306,10 @@ private constructor( customerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders.build(), @@ -267,6 +330,18 @@ private constructor( .apply { currency?.let { put("currency", it) } cursor?.let { put("cursor", it) } + effectiveDateGt?.let { + put("effective_date[gt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateGte?.let { + put("effective_date[gte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLt?.let { + put("effective_date[lt]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + effectiveDateLte?.let { + put("effective_date[lte]", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } includeAllBlocks?.let { put("include_all_blocks", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) @@ -282,6 +357,10 @@ private constructor( customerId == other.customerId && currency == other.currency && cursor == other.cursor && + effectiveDateGt == other.effectiveDateGt && + effectiveDateGte == other.effectiveDateGte && + effectiveDateLt == other.effectiveDateLt && + effectiveDateLte == other.effectiveDateLte && includeAllBlocks == other.includeAllBlocks && limit == other.limit && additionalHeaders == other.additionalHeaders && @@ -293,6 +372,10 @@ private constructor( customerId, currency, cursor, + effectiveDateGt, + effectiveDateGte, + effectiveDateLt, + effectiveDateLte, includeAllBlocks, limit, additionalHeaders, @@ -300,5 +383,5 @@ private constructor( ) override fun toString() = - "CustomerCreditListParams{customerId=$customerId, currency=$currency, cursor=$cursor, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditListParams{customerId=$customerId, currency=$currency, cursor=$cursor, effectiveDateGt=$effectiveDateGt, effectiveDateGte=$effectiveDateGte, effectiveDateLt=$effectiveDateLt, effectiveDateLte=$effectiveDateLte, includeAllBlocks=$includeAllBlocks, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index 516d91b45..842c93dbe 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -30,6 +30,7 @@ private constructor( private val expiryDate: JsonField, private val filters: JsonField>, private val maximumInitialBalance: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val status: JsonField, private val additionalProperties: MutableMap, @@ -51,6 +52,7 @@ private constructor( @JsonProperty("maximum_initial_balance") @ExcludeMissing maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -62,6 +64,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, mutableMapOf(), @@ -104,6 +107,16 @@ private constructor( fun maximumInitialBalance(): Optional = maximumInitialBalance.getOptional("maximum_initial_balance") + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -165,6 +178,13 @@ private constructor( @ExcludeMissing fun _maximumInitialBalance(): JsonField = maximumInitialBalance + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -207,6 +227,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -223,6 +244,7 @@ private constructor( private var expiryDate: JsonField? = null private var filters: JsonField>? = null private var maximumInitialBalance: JsonField? = null + private var metadata: JsonField? = null private var perUnitCostBasis: JsonField? = null private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -235,6 +257,7 @@ private constructor( expiryDate = customerCreditListResponse.expiryDate filters = customerCreditListResponse.filters.map { it.toMutableList() } maximumInitialBalance = customerCreditListResponse.maximumInitialBalance + metadata = customerCreditListResponse.metadata perUnitCostBasis = customerCreditListResponse.perUnitCostBasis status = customerCreditListResponse.status additionalProperties = customerCreditListResponse.additionalProperties.toMutableMap() @@ -348,6 +371,22 @@ private constructor( this.maximumInitialBalance = maximumInitialBalance } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun perUnitCostBasis(perUnitCostBasis: String?) = perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) @@ -408,6 +447,7 @@ private constructor( * .expiryDate() * .filters() * .maximumInitialBalance() + * .metadata() * .perUnitCostBasis() * .status() * ``` @@ -422,6 +462,7 @@ private constructor( checkRequired("expiryDate", expiryDate), checkRequired("filters", filters).map { it.toImmutable() }, checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("metadata", metadata), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("status", status), additionalProperties.toMutableMap(), @@ -430,6 +471,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditListResponse = apply { if (validated) { return@apply @@ -441,6 +490,7 @@ private constructor( expiryDate() filters().forEach { it.validate() } maximumInitialBalance() + metadata().validate() perUnitCostBasis() status().validate() validated = true @@ -467,6 +517,7 @@ private constructor( (if (expiryDate.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumInitialBalance.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) @@ -673,6 +724,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -788,6 +848,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -917,6 +987,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -977,6 +1057,119 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1063,6 +1256,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -1113,6 +1315,7 @@ private constructor( expiryDate == other.expiryDate && filters == other.filters && maximumInitialBalance == other.maximumInitialBalance && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties @@ -1126,6 +1329,7 @@ private constructor( expiryDate, filters, maximumInitialBalance, + metadata, perUnitCostBasis, status, additionalProperties, @@ -1135,5 +1339,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditListResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + "CustomerCreditListResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, filters=$filters, maximumInitialBalance=$maximumInitialBalance, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" } 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 c2a529620..e07a893f0 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 @@ -966,6 +966,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1294,6 +1303,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InvoiceSettings = apply { if (validated) { return@apply @@ -1447,6 +1465,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExpiresAfterUnit = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt index e43937f1b..9c1f2426f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt @@ -431,6 +431,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditTopUpCreateByExternalIdResponse = apply { if (validated) { return@apply @@ -562,6 +570,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExpiresAfterUnit = apply { if (validated) { return@apply 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 b81a4b6de..7e54a0d23 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 @@ -959,6 +959,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1287,6 +1296,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InvoiceSettings = apply { if (validated) { return@apply @@ -1440,6 +1458,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExpiresAfterUnit = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt index 9340d1915..6a6158c6c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt @@ -429,6 +429,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditTopUpCreateResponse = apply { if (validated) { return@apply @@ -560,6 +568,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExpiresAfterUnit = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt index f0f227494..0ee42c465 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageResponse.kt @@ -195,6 +195,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditTopUpListByExternalIdPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt index 2fe145ba0..4fda300bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt @@ -430,6 +430,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditTopUpListByExternalIdResponse = apply { if (validated) { return@apply @@ -561,6 +569,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExpiresAfterUnit = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt index 03bbd399e..9cffc43e3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageResponse.kt @@ -193,6 +193,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditTopUpListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt index 78f8c707e..e9f7fdd00 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt @@ -429,6 +429,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerCreditTopUpListResponse = apply { if (validated) { return@apply @@ -560,6 +568,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExpiresAfterUnit = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt index b935befe7..f540b3e1c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfig.kt @@ -193,6 +193,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerHierarchyConfig = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt index e28c00422..1f1c4600a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageResponse.kt @@ -185,6 +185,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt index ff8e0eb43..a9a96c2f3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinified.kt @@ -175,6 +175,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerMinified = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt index 09bcbb95c..92da3a9be 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxId.kt @@ -74,11 +74,13 @@ import kotlin.jvm.optionals.getOrNull * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -90,6 +92,7 @@ import kotlin.jvm.optionals.getOrNull * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -120,9 +123,11 @@ import kotlin.jvm.optionals.getOrNull * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -140,6 +145,7 @@ import kotlin.jvm.optionals.getOrNull * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -334,6 +340,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): CustomerTaxId = apply { if (validated) { return@apply @@ -440,12 +454,12 @@ private constructor( @JvmField val CV = of("CV") - @JvmField val DE = of("DE") - @JvmField val CY = of("CY") @JvmField val CZ = of("CZ") + @JvmField val DE = of("DE") + @JvmField val DK = of("DK") @JvmField val DO = of("DO") @@ -464,12 +478,16 @@ private constructor( @JvmField val FI = of("FI") + @JvmField val FO = of("FO") + @JvmField val FR = of("FR") @JvmField val GB = of("GB") @JvmField val GE = of("GE") + @JvmField val GI = of("GI") + @JvmField val GN = of("GN") @JvmField val GR = of("GR") @@ -508,6 +526,8 @@ private constructor( @JvmField val LI = of("LI") + @JvmField val LK = of("LK") + @JvmField val LT = of("LT") @JvmField val LU = of("LU") @@ -550,6 +570,8 @@ private constructor( @JvmField val PT = of("PT") + @JvmField val PY = of("PY") + @JvmField val RO = of("RO") @JvmField val RS = of("RS") @@ -638,9 +660,9 @@ private constructor( CO, CR, CV, - DE, CY, CZ, + DE, DK, DO, EC, @@ -650,9 +672,11 @@ private constructor( ET, EU, FI, + FO, FR, GB, GE, + GI, GN, GR, HK, @@ -672,6 +696,7 @@ private constructor( KZ, LA, LI, + LK, LT, LU, LV, @@ -693,6 +718,7 @@ private constructor( PH, PL, PT, + PY, RO, RS, RU, @@ -762,9 +788,9 @@ private constructor( CO, CR, CV, - DE, CY, CZ, + DE, DK, DO, EC, @@ -774,9 +800,11 @@ private constructor( ET, EU, FI, + FO, FR, GB, GE, + GI, GN, GR, HK, @@ -796,6 +824,7 @@ private constructor( KZ, LA, LI, + LK, LT, LU, LV, @@ -817,6 +846,7 @@ private constructor( PH, PL, PT, + PY, RO, RS, RU, @@ -887,9 +917,9 @@ private constructor( CO -> Value.CO CR -> Value.CR CV -> Value.CV - DE -> Value.DE CY -> Value.CY CZ -> Value.CZ + DE -> Value.DE DK -> Value.DK DO -> Value.DO EC -> Value.EC @@ -899,9 +929,11 @@ private constructor( ET -> Value.ET EU -> Value.EU FI -> Value.FI + FO -> Value.FO FR -> Value.FR GB -> Value.GB GE -> Value.GE + GI -> Value.GI GN -> Value.GN GR -> Value.GR HK -> Value.HK @@ -921,6 +953,7 @@ private constructor( KZ -> Value.KZ LA -> Value.LA LI -> Value.LI + LK -> Value.LK LT -> Value.LT LU -> Value.LU LV -> Value.LV @@ -942,6 +975,7 @@ private constructor( PH -> Value.PH PL -> Value.PL PT -> Value.PT + PY -> Value.PY RO -> Value.RO RS -> Value.RS RU -> Value.RU @@ -1012,9 +1046,9 @@ private constructor( CO -> Known.CO CR -> Known.CR CV -> Known.CV - DE -> Known.DE CY -> Known.CY CZ -> Known.CZ + DE -> Known.DE DK -> Known.DK DO -> Known.DO EC -> Known.EC @@ -1024,9 +1058,11 @@ private constructor( ET -> Known.ET EU -> Known.EU FI -> Known.FI + FO -> Known.FO FR -> Known.FR GB -> Known.GB GE -> Known.GE + GI -> Known.GI GN -> Known.GN GR -> Known.GR HK -> Known.HK @@ -1046,6 +1082,7 @@ private constructor( KZ -> Known.KZ LA -> Known.LA LI -> Known.LI + LK -> Known.LK LT -> Known.LT LU -> Known.LU LV -> Known.LV @@ -1067,6 +1104,7 @@ private constructor( PH -> Known.PH PL -> Known.PL PT -> Known.PT + PY -> Known.PY RO -> Known.RO RS -> Known.RS RU -> Known.RU @@ -1110,6 +1148,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Country = apply { if (validated) { return@apply @@ -1252,10 +1299,14 @@ private constructor( @JvmField val EU_OSS_VAT = of("eu_oss_vat") + @JvmField val FO_VAT = of("fo_vat") + @JvmField val GB_VAT = of("gb_vat") @JvmField val GE_VAT = of("ge_vat") + @JvmField val GI_TIN = of("gi_tin") + @JvmField val GN_NIF = of("gn_nif") @JvmField val HK_BR = of("hk_br") @@ -1272,6 +1323,8 @@ private constructor( @JvmField val IS_VAT = of("is_vat") + @JvmField val IT_CF = of("it_cf") + @JvmField val JP_CN = of("jp_cn") @JvmField val JP_RN = of("jp_rn") @@ -1294,6 +1347,8 @@ private constructor( @JvmField val LI_VAT = of("li_vat") + @JvmField val LK_VAT = of("lk_vat") + @JvmField val MA_VAT = of("ma_vat") @JvmField val MD_VAT = of("md_vat") @@ -1328,6 +1383,10 @@ private constructor( @JvmField val PH_TIN = of("ph_tin") + @JvmField val PL_NIP = of("pl_nip") + + @JvmField val PY_RUC = of("py_ruc") + @JvmField val RO_TIN = of("ro_tin") @JvmField val RS_PIB = of("rs_pib") @@ -1432,8 +1491,10 @@ private constructor( ES_CIF, ET_TIN, EU_OSS_VAT, + FO_VAT, GB_VAT, GE_VAT, + GI_TIN, GN_NIF, HK_BR, HR_OIB, @@ -1442,6 +1503,7 @@ private constructor( IL_VAT, IN_GST, IS_VAT, + IT_CF, JP_CN, JP_RN, JP_TRN, @@ -1453,6 +1515,7 @@ private constructor( LA_TIN, LI_UID, LI_VAT, + LK_VAT, MA_VAT, MD_VAT, ME_PIB, @@ -1470,6 +1533,8 @@ private constructor( OM_VAT, PE_RUC, PH_TIN, + PL_NIP, + PY_RUC, RO_TIN, RS_PIB, RU_INN, @@ -1554,8 +1619,10 @@ private constructor( ES_CIF, ET_TIN, EU_OSS_VAT, + FO_VAT, GB_VAT, GE_VAT, + GI_TIN, GN_NIF, HK_BR, HR_OIB, @@ -1564,6 +1631,7 @@ private constructor( IL_VAT, IN_GST, IS_VAT, + IT_CF, JP_CN, JP_RN, JP_TRN, @@ -1575,6 +1643,7 @@ private constructor( LA_TIN, LI_UID, LI_VAT, + LK_VAT, MA_VAT, MD_VAT, ME_PIB, @@ -1592,6 +1661,8 @@ private constructor( OM_VAT, PE_RUC, PH_TIN, + PL_NIP, + PY_RUC, RO_TIN, RS_PIB, RU_INN, @@ -1677,8 +1748,10 @@ private constructor( ES_CIF -> Value.ES_CIF ET_TIN -> Value.ET_TIN EU_OSS_VAT -> Value.EU_OSS_VAT + FO_VAT -> Value.FO_VAT GB_VAT -> Value.GB_VAT GE_VAT -> Value.GE_VAT + GI_TIN -> Value.GI_TIN GN_NIF -> Value.GN_NIF HK_BR -> Value.HK_BR HR_OIB -> Value.HR_OIB @@ -1687,6 +1760,7 @@ private constructor( IL_VAT -> Value.IL_VAT IN_GST -> Value.IN_GST IS_VAT -> Value.IS_VAT + IT_CF -> Value.IT_CF JP_CN -> Value.JP_CN JP_RN -> Value.JP_RN JP_TRN -> Value.JP_TRN @@ -1698,6 +1772,7 @@ private constructor( LA_TIN -> Value.LA_TIN LI_UID -> Value.LI_UID LI_VAT -> Value.LI_VAT + LK_VAT -> Value.LK_VAT MA_VAT -> Value.MA_VAT MD_VAT -> Value.MD_VAT ME_PIB -> Value.ME_PIB @@ -1715,6 +1790,8 @@ private constructor( OM_VAT -> Value.OM_VAT PE_RUC -> Value.PE_RUC PH_TIN -> Value.PH_TIN + PL_NIP -> Value.PL_NIP + PY_RUC -> Value.PY_RUC RO_TIN -> Value.RO_TIN RS_PIB -> Value.RS_PIB RU_INN -> Value.RU_INN @@ -1800,8 +1877,10 @@ private constructor( ES_CIF -> Known.ES_CIF ET_TIN -> Known.ET_TIN EU_OSS_VAT -> Known.EU_OSS_VAT + FO_VAT -> Known.FO_VAT GB_VAT -> Known.GB_VAT GE_VAT -> Known.GE_VAT + GI_TIN -> Known.GI_TIN GN_NIF -> Known.GN_NIF HK_BR -> Known.HK_BR HR_OIB -> Known.HR_OIB @@ -1810,6 +1889,7 @@ private constructor( IL_VAT -> Known.IL_VAT IN_GST -> Known.IN_GST IS_VAT -> Known.IS_VAT + IT_CF -> Known.IT_CF JP_CN -> Known.JP_CN JP_RN -> Known.JP_RN JP_TRN -> Known.JP_TRN @@ -1821,6 +1901,7 @@ private constructor( LA_TIN -> Known.LA_TIN LI_UID -> Known.LI_UID LI_VAT -> Known.LI_VAT + LK_VAT -> Known.LK_VAT MA_VAT -> Known.MA_VAT MD_VAT -> Known.MD_VAT ME_PIB -> Known.ME_PIB @@ -1838,6 +1919,8 @@ private constructor( OM_VAT -> Known.OM_VAT PE_RUC -> Known.PE_RUC PH_TIN -> Known.PH_TIN + PL_NIP -> Known.PL_NIP + PY_RUC -> Known.PY_RUC RO_TIN -> Known.RO_TIN RS_PIB -> Known.RS_PIB RU_INN -> Known.RU_INN @@ -1882,6 +1965,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply 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 dec9f8ada..ef9f675fe 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 @@ -93,8 +93,9 @@ private constructor( fun billingAddress(): Optional = body.billingAddress() /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only be + * set if the customer does not already have a currency configured. If not set at creation or + * update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -258,11 +259,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -274,6 +277,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -304,9 +308,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -324,6 +330,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -685,8 +692,9 @@ private constructor( } /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = apply { body.currency(currency) } @@ -1113,11 +1121,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1129,6 +1139,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1159,9 +1170,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1179,6 +1192,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -1508,8 +1522,9 @@ private constructor( fun billingAddress(): Optional = billingAddress.getOptional("billing_address") /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1679,11 +1694,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1695,6 +1712,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1725,9 +1743,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1745,6 +1765,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -2155,8 +2176,9 @@ private constructor( } /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set - * at creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can + * only be set if the customer does not already have a currency configured. If not set + * at creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -2593,11 +2615,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -2609,6 +2633,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -2639,9 +2664,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -2659,6 +2686,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -2746,6 +2774,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -2931,6 +2968,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -3099,6 +3145,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentConfiguration = apply { if (validated) { return@apply @@ -3130,6 +3185,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerType: JsonField, + private val defaultSharedPaymentToken: JsonField, private val excludedPaymentMethodTypes: JsonField>, private val additionalProperties: MutableMap, ) { @@ -3139,10 +3195,18 @@ private constructor( @JsonProperty("provider_type") @ExcludeMissing providerType: JsonField = JsonMissing.of(), + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + defaultSharedPaymentToken: JsonField = JsonMissing.of(), @JsonProperty("excluded_payment_method_types") @ExcludeMissing excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), - ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + ) : this( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + mutableMapOf(), + ) /** * The payment provider to configure. @@ -3153,6 +3217,17 @@ private constructor( */ fun providerType(): ProviderType = providerType.getRequired("provider_type") + /** + * The ID of a shared payment token granted by an agent to use as the default payment + * instrument for this customer. When set, auto-collection will use this token instead + * of the customer's default payment method. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultSharedPaymentToken(): Optional = + defaultSharedPaymentToken.getOptional("default_shared_payment_token") + /** * List of Stripe payment method types to exclude for this customer. Excluded payment * methods will not be available for the customer to select during payment, and will not @@ -3176,6 +3251,16 @@ private constructor( @ExcludeMissing fun _providerType(): JsonField = providerType + /** + * Returns the raw JSON value of [defaultSharedPaymentToken]. + * + * Unlike [defaultSharedPaymentToken], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + fun _defaultSharedPaymentToken(): JsonField = defaultSharedPaymentToken + /** * Returns the raw JSON value of [excludedPaymentMethodTypes]. * @@ -3215,12 +3300,14 @@ private constructor( class Builder internal constructor() { private var providerType: JsonField? = null + private var defaultSharedPaymentToken: JsonField = JsonMissing.of() private var excludedPaymentMethodTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(paymentProvider: PaymentProvider) = apply { providerType = paymentProvider.providerType + defaultSharedPaymentToken = paymentProvider.defaultSharedPaymentToken excludedPaymentMethodTypes = paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } additionalProperties = paymentProvider.additionalProperties.toMutableMap() @@ -3241,6 +3328,33 @@ private constructor( this.providerType = providerType } + /** + * The ID of a shared payment token granted by an agent to use as the default + * payment instrument for this customer. When set, auto-collection will use this + * token instead of the customer's default payment method. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: String?) = + defaultSharedPaymentToken(JsonField.ofNullable(defaultSharedPaymentToken)) + + /** + * Alias for calling [Builder.defaultSharedPaymentToken] with + * `defaultSharedPaymentToken.orElse(null)`. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: Optional) = + defaultSharedPaymentToken(defaultSharedPaymentToken.getOrNull()) + + /** + * Sets [Builder.defaultSharedPaymentToken] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSharedPaymentToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: JsonField) = + apply { + this.defaultSharedPaymentToken = defaultSharedPaymentToken + } + /** * List of Stripe payment method types to exclude for this customer. Excluded * payment methods will not be available for the customer to select during payment, @@ -3315,6 +3429,7 @@ private constructor( fun build(): PaymentProvider = PaymentProvider( checkRequired("providerType", providerType), + defaultSharedPaymentToken, (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -3322,12 +3437,23 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply } providerType().validate() + defaultSharedPaymentToken() excludedPaymentMethodTypes() validated = true } @@ -3349,6 +3475,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (providerType.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultSharedPaymentToken.asKnown().isPresent) 1 else 0) + (excludedPaymentMethodTypes.asKnown().getOrNull()?.size ?: 0) /** The payment provider to configure. */ @@ -3441,6 +3568,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ProviderType = apply { if (validated) { return@apply @@ -3486,18 +3623,24 @@ private constructor( return other is PaymentProvider && providerType == other.providerType && + defaultSharedPaymentToken == other.defaultSharedPaymentToken && excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + Objects.hash( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + "PaymentProvider{providerType=$providerType, defaultSharedPaymentToken=$defaultSharedPaymentToken, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -3550,6 +3693,8 @@ private constructor( @JvmField val NETSUITE = of("netsuite") + @JvmField val NETSUITE_AMPERSAND = of("netsuite_ampersand") + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) } @@ -3560,6 +3705,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, } /** @@ -3577,6 +3723,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, /** * An enum member indicating that [PaymentProvider] was instantiated with an unknown * value. @@ -3598,6 +3745,7 @@ private constructor( STRIPE_CHARGE -> Value.STRIPE_CHARGE STRIPE_INVOICE -> Value.STRIPE_INVOICE NETSUITE -> Value.NETSUITE + NETSUITE_AMPERSAND -> Value.NETSUITE_AMPERSAND else -> Value._UNKNOWN } @@ -3616,6 +3764,7 @@ private constructor( STRIPE_CHARGE -> Known.STRIPE_CHARGE STRIPE_INVOICE -> Known.STRIPE_INVOICE NETSUITE -> Known.NETSUITE + NETSUITE_AMPERSAND -> Known.NETSUITE_AMPERSAND else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") } @@ -3633,6 +3782,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply @@ -3722,6 +3880,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = taxConfiguration.accept(new TaxConfiguration.Visitor>() { + * @Override + * public Optional visitAvalara(NewAvalaraTaxConfiguration avalara) { + * return Optional.of(avalara.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { avalara != null -> visitor.visitAvalara(avalara) @@ -3735,6 +3922,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TaxConfiguration = apply { if (validated) { return@apply @@ -4164,6 +4360,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Numeral = apply { if (validated) { return@apply @@ -4437,6 +4643,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Anrok = apply { if (validated) { return@apply @@ -4710,6 +4926,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Stripe = apply { if (validated) { return@apply 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 971b2f8ad..d13a7cfcb 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 @@ -36,8 +36,9 @@ import kotlin.jvm.optionals.getOrNull /** * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, * `email`, `email_delivery`, `tax_id`, `auto_collection`, `metadata`, `shipping_address`, - * `billing_address`, and `additional_emails` of an existing customer. Other fields on a customer - * are currently immutable. + * `billing_address`, `additional_emails`, and `currency` of an existing customer. `currency` can + * only be set if it has not already been set on the customer. Other fields on a customer are + * currently immutable. */ class CustomerUpdateParams private constructor( @@ -94,8 +95,9 @@ private constructor( fun billingAddress(): Optional = body.billingAddress() /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only be + * set if the customer does not already have a currency configured. If not set at creation or + * update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -259,11 +261,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -275,6 +279,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -305,9 +310,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -325,6 +332,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -681,8 +689,9 @@ private constructor( } /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = apply { body.currency(currency) } @@ -1109,11 +1118,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1125,6 +1136,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1155,9 +1167,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1175,6 +1189,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -1504,8 +1519,9 @@ private constructor( fun billingAddress(): Optional = billingAddress.getOptional("billing_address") /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set at - * creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can only + * be set if the customer does not already have a currency configured. If not set at + * creation or update time, it will be set at subscription creation time. * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1675,11 +1691,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1691,6 +1709,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1721,9 +1740,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1741,6 +1762,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -2151,8 +2173,9 @@ private constructor( } /** - * An ISO 4217 currency string used for the customer's invoices and balance. If not set - * at creation time, will be set at subscription creation time. + * An ISO 4217 currency string used for the customer's invoices and balance. This can + * only be set if the customer does not already have a currency configured. If not set + * at creation or update time, it will be set at subscription creation time. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -2589,11 +2612,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -2605,6 +2630,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -2635,9 +2661,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -2655,6 +2683,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -2742,6 +2771,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -2927,6 +2965,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -3095,6 +3142,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentConfiguration = apply { if (validated) { return@apply @@ -3126,6 +3182,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerType: JsonField, + private val defaultSharedPaymentToken: JsonField, private val excludedPaymentMethodTypes: JsonField>, private val additionalProperties: MutableMap, ) { @@ -3135,10 +3192,18 @@ private constructor( @JsonProperty("provider_type") @ExcludeMissing providerType: JsonField = JsonMissing.of(), + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + defaultSharedPaymentToken: JsonField = JsonMissing.of(), @JsonProperty("excluded_payment_method_types") @ExcludeMissing excludedPaymentMethodTypes: JsonField> = JsonMissing.of(), - ) : this(providerType, excludedPaymentMethodTypes, mutableMapOf()) + ) : this( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + mutableMapOf(), + ) /** * The payment provider to configure. @@ -3149,6 +3214,17 @@ private constructor( */ fun providerType(): ProviderType = providerType.getRequired("provider_type") + /** + * The ID of a shared payment token granted by an agent to use as the default payment + * instrument for this customer. When set, auto-collection will use this token instead + * of the customer's default payment method. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultSharedPaymentToken(): Optional = + defaultSharedPaymentToken.getOptional("default_shared_payment_token") + /** * List of Stripe payment method types to exclude for this customer. Excluded payment * methods will not be available for the customer to select during payment, and will not @@ -3172,6 +3248,16 @@ private constructor( @ExcludeMissing fun _providerType(): JsonField = providerType + /** + * Returns the raw JSON value of [defaultSharedPaymentToken]. + * + * Unlike [defaultSharedPaymentToken], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_shared_payment_token") + @ExcludeMissing + fun _defaultSharedPaymentToken(): JsonField = defaultSharedPaymentToken + /** * Returns the raw JSON value of [excludedPaymentMethodTypes]. * @@ -3211,12 +3297,14 @@ private constructor( class Builder internal constructor() { private var providerType: JsonField? = null + private var defaultSharedPaymentToken: JsonField = JsonMissing.of() private var excludedPaymentMethodTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(paymentProvider: PaymentProvider) = apply { providerType = paymentProvider.providerType + defaultSharedPaymentToken = paymentProvider.defaultSharedPaymentToken excludedPaymentMethodTypes = paymentProvider.excludedPaymentMethodTypes.map { it.toMutableList() } additionalProperties = paymentProvider.additionalProperties.toMutableMap() @@ -3237,6 +3325,33 @@ private constructor( this.providerType = providerType } + /** + * The ID of a shared payment token granted by an agent to use as the default + * payment instrument for this customer. When set, auto-collection will use this + * token instead of the customer's default payment method. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: String?) = + defaultSharedPaymentToken(JsonField.ofNullable(defaultSharedPaymentToken)) + + /** + * Alias for calling [Builder.defaultSharedPaymentToken] with + * `defaultSharedPaymentToken.orElse(null)`. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: Optional) = + defaultSharedPaymentToken(defaultSharedPaymentToken.getOrNull()) + + /** + * Sets [Builder.defaultSharedPaymentToken] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultSharedPaymentToken] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultSharedPaymentToken(defaultSharedPaymentToken: JsonField) = + apply { + this.defaultSharedPaymentToken = defaultSharedPaymentToken + } + /** * List of Stripe payment method types to exclude for this customer. Excluded * payment methods will not be available for the customer to select during payment, @@ -3311,6 +3426,7 @@ private constructor( fun build(): PaymentProvider = PaymentProvider( checkRequired("providerType", providerType), + defaultSharedPaymentToken, (excludedPaymentMethodTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -3318,12 +3434,23 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply } providerType().validate() + defaultSharedPaymentToken() excludedPaymentMethodTypes() validated = true } @@ -3345,6 +3472,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (providerType.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultSharedPaymentToken.asKnown().isPresent) 1 else 0) + (excludedPaymentMethodTypes.asKnown().getOrNull()?.size ?: 0) /** The payment provider to configure. */ @@ -3437,6 +3565,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ProviderType = apply { if (validated) { return@apply @@ -3482,18 +3620,24 @@ private constructor( return other is PaymentProvider && providerType == other.providerType && + defaultSharedPaymentToken == other.defaultSharedPaymentToken && excludedPaymentMethodTypes == other.excludedPaymentMethodTypes && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(providerType, excludedPaymentMethodTypes, additionalProperties) + Objects.hash( + providerType, + defaultSharedPaymentToken, + excludedPaymentMethodTypes, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PaymentProvider{providerType=$providerType, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" + "PaymentProvider{providerType=$providerType, defaultSharedPaymentToken=$defaultSharedPaymentToken, excludedPaymentMethodTypes=$excludedPaymentMethodTypes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -3546,6 +3690,8 @@ private constructor( @JvmField val NETSUITE = of("netsuite") + @JvmField val NETSUITE_AMPERSAND = of("netsuite_ampersand") + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) } @@ -3556,6 +3702,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, } /** @@ -3573,6 +3720,7 @@ private constructor( STRIPE_CHARGE, STRIPE_INVOICE, NETSUITE, + NETSUITE_AMPERSAND, /** * An enum member indicating that [PaymentProvider] was instantiated with an unknown * value. @@ -3594,6 +3742,7 @@ private constructor( STRIPE_CHARGE -> Value.STRIPE_CHARGE STRIPE_INVOICE -> Value.STRIPE_INVOICE NETSUITE -> Value.NETSUITE + NETSUITE_AMPERSAND -> Value.NETSUITE_AMPERSAND else -> Value._UNKNOWN } @@ -3612,6 +3761,7 @@ private constructor( STRIPE_CHARGE -> Known.STRIPE_CHARGE STRIPE_INVOICE -> Known.STRIPE_INVOICE NETSUITE -> Known.NETSUITE + NETSUITE_AMPERSAND -> Known.NETSUITE_AMPERSAND else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") } @@ -3629,6 +3779,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply @@ -3718,6 +3877,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = taxConfiguration.accept(new TaxConfiguration.Visitor>() { + * @Override + * public Optional visitAvalara(NewAvalaraTaxConfiguration avalara) { + * return Optional.of(avalara.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { avalara != null -> visitor.visitAvalara(avalara) @@ -3731,6 +3919,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TaxConfiguration = apply { if (validated) { return@apply @@ -4160,6 +4357,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Numeral = apply { if (validated) { return@apply @@ -4433,6 +4640,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Anrok = apply { if (validated) { return@apply @@ -4706,6 +4923,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Stripe = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt index daae7597d..e366c2ede 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DecrementLedgerEntry.kt @@ -181,10 +181,13 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") /** + * This field is deprecated and will always be null. Decrements are not associated with + * individual events. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ - fun eventId(): Optional = eventId.getOptional("event_id") + @Deprecated("deprecated") fun eventId(): Optional = eventId.getOptional("event_id") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -309,7 +312,10 @@ private constructor( * * Unlike [eventId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId + @Deprecated("deprecated") + @JsonProperty("event_id") + @ExcludeMissing + fun _eventId(): JsonField = eventId /** * Returns the raw JSON value of [invoiceId]. @@ -564,9 +570,15 @@ private constructor( this.startingBalance = startingBalance } + /** + * This field is deprecated and will always be null. Decrements are not associated with + * individual events. + */ + @Deprecated("deprecated") fun eventId(eventId: String?) = eventId(JsonField.ofNullable(eventId)) /** Alias for calling [Builder.eventId] with `eventId.orElse(null)`. */ + @Deprecated("deprecated") fun eventId(eventId: Optional) = eventId(eventId.getOrNull()) /** @@ -575,6 +587,7 @@ private constructor( * You should usually call [Builder.eventId] with a well-typed [String] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ + @Deprecated("deprecated") fun eventId(eventId: JsonField) = apply { this.eventId = eventId } fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) @@ -671,6 +684,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): DecrementLedgerEntry = apply { if (validated) { return@apply @@ -816,6 +837,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryStatus = apply { if (validated) { return@apply @@ -936,6 +966,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryType = apply { if (validated) { return@apply @@ -1037,6 +1076,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt index 976f8490d..44fdb7f75 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfiguration.kt @@ -192,6 +192,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): DimensionalPriceConfiguration = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt index 891786ef0..604c82748 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt @@ -21,7 +21,7 @@ import kotlin.jvm.optionals.getOrNull /** * A dimensional price group is used to partition the result of a billable metric by a set of - * dimensions. Prices in a price group must specify the parition used to derive their usage. + * dimensions. Prices in a price group must specify the partition used to derive their usage. */ class DimensionalPriceGroup @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -365,6 +365,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): DimensionalPriceGroup = apply { if (validated) { return@apply @@ -464,6 +472,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt index 00a0c6b61..44188fe94 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt @@ -700,6 +700,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -829,6 +838,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt index d0f0111c1..f4d9ebd6f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdUpdateParams.kt @@ -510,6 +510,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -623,6 +632,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt index e1aae7b91..2d94c062e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupUpdateParams.kt @@ -486,6 +486,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -599,6 +608,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt index c4663fc3c..ecc637a1a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt @@ -187,6 +187,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): DimensionalPriceGroups = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt index 1d09bddd5..da0ce61ca 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt @@ -55,6 +55,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = discount.accept(new Discount.Visitor>() { + * @Override + * public Optional visitPercentage(PercentageDiscount percentage) { + * return Optional.of(percentage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and the + * current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentage != null -> visitor.visitPercentage(percentage) @@ -66,6 +95,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Discount = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt index a42caed76..27a4be490 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverride.kt @@ -288,6 +288,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): DiscountOverride = apply { if (validated) { return@apply @@ -415,6 +423,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt index be5f47dbe..bd4debe80 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt @@ -240,6 +240,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EvaluatePriceGroup = apply { if (validated) { return@apply @@ -300,6 +308,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = groupingValue.accept(new GroupingValue.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -310,6 +347,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupingValue = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt index c45c26b35..610cd4a71 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt @@ -559,6 +559,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventBackfillCloseResponse = apply { if (validated) { return@apply @@ -704,6 +712,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt index 530239c99..731f7e556 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt @@ -25,7 +25,8 @@ import kotlin.jvm.optionals.getOrNull * Creating the backfill enables adding or replacing past events, even those that are older than the * ingestion grace period. Performing a backfill in Orb involves 3 steps: * 1. Create the backfill, specifying its parameters. - * 2. [Ingest](ingest) usage events, referencing the backfill (query parameter `backfill_id`). + * 2. [Ingest](/api-reference/event/ingest-events) usage events, referencing the backfill (query + * parameter `backfill_id`). * 3. [Close](close-backfill) the backfill, propagating the update in past usage throughout Orb. * * Changes from a backfill are not reflected until the backfill is closed, so you won’t need to @@ -942,6 +943,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt index 092e67645..37c0710be 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt @@ -559,6 +559,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventBackfillCreateResponse = apply { if (validated) { return@apply @@ -704,6 +712,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt index 6c8c8e4c0..74314ab9d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt @@ -559,6 +559,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventBackfillFetchResponse = apply { if (validated) { return@apply @@ -704,6 +712,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt index 196803903..c383855c1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageResponse.kt @@ -190,6 +190,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventBackfillListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt index 6a50942be..f7aa8074e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt @@ -14,8 +14,7 @@ import kotlin.jvm.optionals.getOrNull * * The list of backfills is ordered starting from the most recently created backfill. The response * also includes [`pagination_metadata`](/api-reference/pagination), which lets the caller retrieve - * the next page of results if they exist. More information about pagination can be found in the - * [Pagination-metadata schema](pagination). + * the next page of results if they exist. */ class EventBackfillListParams private constructor( diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt index 4cc968627..5f933e9bc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt @@ -559,6 +559,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventBackfillListResponse = apply { if (validated) { return@apply @@ -704,6 +712,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt index a5e6e9ba3..dc4356351 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt @@ -559,6 +559,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventBackfillRevertResponse = apply { if (validated) { return@apply @@ -704,6 +712,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt index 93d124a02..7b65184d0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt @@ -131,6 +131,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventDeprecateResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt index e944a2c73..7957b420e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt @@ -613,6 +613,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1010,6 +1019,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Event = apply { if (validated) { return@apply @@ -1112,6 +1130,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Properties = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt index e9c942c75..2496efd24 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt @@ -198,6 +198,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventIngestResponse = apply { if (validated) { return@apply @@ -406,6 +414,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ValidationFailed = apply { if (validated) { return@apply @@ -640,6 +657,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Debug = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt index 3f722203a..e2d9b52db 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt @@ -588,6 +588,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt index 168a79bfa..96ef3d38f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt @@ -146,6 +146,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventSearchResponse = apply { if (validated) { return@apply @@ -565,6 +573,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -669,6 +686,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Properties = apply { if (validated) { return@apply 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 9d201bf0e..051501a51 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 @@ -739,6 +739,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -867,6 +876,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Properties = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt index 532c6da51..8bc1269b7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt @@ -130,6 +130,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventUpdateResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt index d8cb14609..3fb702bb8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt @@ -145,6 +145,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): EventVolumes = apply { if (validated) { return@apply @@ -369,6 +377,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt index b325ddb28..f73f314a2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ExpirationChangeLedgerEntry.kt @@ -621,6 +621,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): ExpirationChangeLedgerEntry = apply { if (validated) { return@apply @@ -762,6 +770,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryStatus = apply { if (validated) { return@apply @@ -882,6 +899,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryType = apply { if (validated) { return@apply @@ -983,6 +1009,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt index 4a9a30e8e..b2470d12b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntry.kt @@ -232,6 +232,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): FixedFeeQuantityScheduleEntry = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt index 3fea24c36..6eb10514a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityTransition.kt @@ -196,6 +196,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): FixedFeeQuantityTransition = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt index 98b22599e..1a288cbd5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/IncrementLedgerEntry.kt @@ -631,6 +631,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): IncrementLedgerEntry = apply { if (validated) { return@apply @@ -772,6 +780,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryStatus = apply { if (validated) { return@apply @@ -892,6 +909,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryType = apply { if (validated) { return@apply @@ -993,6 +1019,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply 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 c1f6102c2..4e5d8ebe7 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 @@ -354,11 +354,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -370,6 +372,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -400,9 +403,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -420,6 +425,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -450,6 +456,11 @@ private constructor( /** * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the * first discount in the list will be returned. If the list is empty, `None` will be returned. + * + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = invoice.discount().convert(MyClass.class); + * ``` */ @Deprecated("deprecated") @JsonProperty("discount") @@ -1397,11 +1408,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1413,6 +1426,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1443,9 +1457,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1463,6 +1479,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -2218,6 +2235,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Invoice = apply { if (validated) { return@apply @@ -2611,6 +2636,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AutoCollection = apply { if (validated) { return@apply @@ -3000,6 +3034,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CreditNote = apply { if (validated) { return@apply @@ -3552,6 +3595,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CustomerBalanceTransaction = apply { if (validated) { return@apply @@ -3734,6 +3786,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Action = apply { if (validated) { return@apply @@ -3859,6 +3921,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply @@ -4034,6 +4106,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InvoiceSource = apply { if (validated) { return@apply @@ -4815,6 +4896,13 @@ private constructor( fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -4902,6 +4990,16 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: Price.MinimumComposite) = price(Price.ofMinimumComposite(minimumComposite)) @@ -5124,6 +5222,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): LineItem = apply { if (validated) { return@apply @@ -5233,6 +5340,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitUsageDiscount(MonetaryUsageDiscountAdjustment usageDiscount) { + * return Optional.of(usageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) @@ -5246,6 +5383,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -5504,6 +5651,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = subLineItem.accept(new SubLineItem.Visitor>() { + * @Override + * public Optional visitMatrix(MatrixSubLineItem matrix) { + * return Optional.of(matrix.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { matrix != null -> visitor.visitMatrix(matrix) @@ -5514,6 +5691,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): SubLineItem = apply { if (validated) { return@apply @@ -5787,6 +5974,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -6204,6 +6400,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentAttempt = apply { if (validated) { return@apply @@ -6330,6 +6535,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply @@ -6507,6 +6722,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index 438ed64b2..742c4628d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -67,6 +67,15 @@ private constructor( */ fun lineItems(): List = body.lineItems() + /** + * Determines whether this invoice will automatically attempt to charge a saved payment method, + * if any. If not specified, the invoice inherits the customer's auto_collection setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoCollection(): Optional = body.autoCollection() + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -163,6 +172,13 @@ private constructor( */ fun _lineItems(): JsonField> = body._lineItems() + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoCollection(): JsonField = body._autoCollection() + /** * Returns the raw JSON value of [customerId]. * @@ -267,8 +283,8 @@ private constructor( * - [currency] * - [invoiceDate] * - [lineItems] + * - [autoCollection] * - [customerId] - * - [discount] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -321,6 +337,35 @@ private constructor( */ fun addLineItem(lineItem: LineItem) = apply { body.addLineItem(lineItem) } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. If not specified, the invoice inherits the customer's auto_collection + * setting. + */ + fun autoCollection(autoCollection: Boolean?) = apply { body.autoCollection(autoCollection) } + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -680,6 +725,7 @@ private constructor( private val currency: JsonField, private val invoiceDate: JsonField, private val lineItems: JsonField>, + private val autoCollection: JsonField, private val customerId: JsonField, private val discount: JsonField, private val dueDate: JsonField, @@ -702,6 +748,9 @@ private constructor( @JsonProperty("line_items") @ExcludeMissing lineItems: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), @JsonProperty("customer_id") @ExcludeMissing customerId: JsonField = JsonMissing.of(), @@ -726,6 +775,7 @@ private constructor( currency, invoiceDate, lineItems, + autoCollection, customerId, discount, dueDate, @@ -760,6 +810,16 @@ private constructor( */ fun lineItems(): List = lineItems.getRequired("line_items") + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. If not specified, the invoice inherits the customer's auto_collection + * setting. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoCollection(): Optional = autoCollection.getOptional("auto_collection") + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -861,6 +921,16 @@ private constructor( @ExcludeMissing fun _lineItems(): JsonField> = lineItems + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + /** * Returns the raw JSON value of [customerId]. * @@ -958,6 +1028,7 @@ private constructor( private var currency: JsonField? = null private var invoiceDate: JsonField? = null private var lineItems: JsonField>? = null + private var autoCollection: JsonField = JsonMissing.of() private var customerId: JsonField = JsonMissing.of() private var discount: JsonField = JsonMissing.of() private var dueDate: JsonField = JsonMissing.of() @@ -973,6 +1044,7 @@ private constructor( currency = body.currency invoiceDate = body.invoiceDate lineItems = body.lineItems.map { it.toMutableList() } + autoCollection = body.autoCollection customerId = body.customerId discount = body.discount dueDate = body.dueDate @@ -1041,6 +1113,36 @@ private constructor( } } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. If not specified, the invoice inherits the customer's auto_collection + * setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -1307,6 +1409,7 @@ private constructor( checkRequired("currency", currency), checkRequired("invoiceDate", invoiceDate), checkRequired("lineItems", lineItems).map { it.toImmutable() }, + autoCollection, customerId, discount, dueDate, @@ -1321,6 +1424,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1329,6 +1441,7 @@ private constructor( currency() invoiceDate() lineItems().forEach { it.validate() } + autoCollection() customerId() discount().ifPresent { it.validate() } dueDate().ifPresent { it.validate() } @@ -1359,6 +1472,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (invoiceDate.asKnown().isPresent) 1 else 0) + (lineItems.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + (if (customerId.asKnown().isPresent) 1 else 0) + (discount.asKnown().getOrNull()?.validity() ?: 0) + (dueDate.asKnown().getOrNull()?.validity() ?: 0) + @@ -1377,6 +1491,7 @@ private constructor( currency == other.currency && invoiceDate == other.invoiceDate && lineItems == other.lineItems && + autoCollection == other.autoCollection && customerId == other.customerId && discount == other.discount && dueDate == other.dueDate && @@ -1393,6 +1508,7 @@ private constructor( currency, invoiceDate, lineItems, + autoCollection, customerId, discount, dueDate, @@ -1408,7 +1524,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{currency=$currency, invoiceDate=$invoiceDate, lineItems=$lineItems, customerId=$customerId, discount=$discount, dueDate=$dueDate, externalCustomerId=$externalCustomerId, memo=$memo, metadata=$metadata, netTerms=$netTerms, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" + "Body{currency=$currency, invoiceDate=$invoiceDate, lineItems=$lineItems, autoCollection=$autoCollection, customerId=$customerId, discount=$discount, dueDate=$dueDate, externalCustomerId=$externalCustomerId, memo=$memo, metadata=$metadata, netTerms=$netTerms, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" } class LineItem @@ -1743,6 +1859,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): LineItem = apply { if (validated) { return@apply @@ -1867,6 +1992,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1967,6 +2102,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dueDate.accept(new DueDate.Visitor>() { + * @Override + * public Optional visitDate(LocalDate date) { + * return Optional.of(date.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { date != null -> visitor.visitDate(date) @@ -1976,6 +2140,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DueDate = apply { if (validated) { return@apply @@ -2176,6 +2349,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply 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 c57bd6e61..f9d36e531 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 @@ -347,11 +347,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -363,6 +365,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -393,9 +396,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -413,6 +418,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -443,6 +449,11 @@ private constructor( /** * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the * first discount in the list will be returned. If the list is empty, `None` will be returned. + * + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = invoiceFetchUpcomingResponse.discount().convert(MyClass.class); + * ``` */ @Deprecated("deprecated") @JsonProperty("discount") @@ -1391,11 +1402,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1407,6 +1420,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1437,9 +1451,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1457,6 +1473,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -2212,6 +2229,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): InvoiceFetchUpcomingResponse = apply { if (validated) { return@apply @@ -2605,6 +2630,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AutoCollection = apply { if (validated) { return@apply @@ -2994,6 +3028,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CreditNote = apply { if (validated) { return@apply @@ -3546,6 +3589,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CustomerBalanceTransaction = apply { if (validated) { return@apply @@ -3728,6 +3780,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Action = apply { if (validated) { return@apply @@ -3853,6 +3915,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply @@ -4028,6 +4100,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InvoiceSource = apply { if (validated) { return@apply @@ -4809,6 +4890,13 @@ private constructor( fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -4896,6 +4984,16 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: Price.MinimumComposite) = price(Price.ofMinimumComposite(minimumComposite)) @@ -5118,6 +5216,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): LineItem = apply { if (validated) { return@apply @@ -5227,6 +5334,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitUsageDiscount(MonetaryUsageDiscountAdjustment usageDiscount) { + * return Optional.of(usageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) @@ -5240,6 +5377,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -5498,6 +5645,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = subLineItem.accept(new SubLineItem.Visitor>() { + * @Override + * public Optional visitMatrix(MatrixSubLineItem matrix) { + * return Optional.of(matrix.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { matrix != null -> visitor.visitMatrix(matrix) @@ -5508,6 +5685,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): SubLineItem = apply { if (validated) { return@apply @@ -5781,6 +5968,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -6198,6 +6394,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentAttempt = apply { if (validated) { return@apply @@ -6324,6 +6529,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply @@ -6501,6 +6716,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply 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 1abaccac2..9d19f0acc 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 @@ -375,6 +375,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt new file mode 100644 index 000000000..a7e50cf7d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryParams.kt @@ -0,0 +1,452 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.Params +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 + * invoices where status is `draft`, `will_auto_issue` is false, and an `eligible_to_issue_at` is a + * time in the past. Issuing an invoice could possibly trigger side effects, some of which could be + * customer-visible (e.g. sending emails, auto-collecting payment, syncing the invoice to external + * providers, etc). + * + * This is a lighter-weight alternative to the issue invoice endpoint, returning an invoice summary + * without any line item details. + */ +class InvoiceIssueSummaryParams +private constructor( + private val invoiceId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun invoiceId(): Optional = Optional.ofNullable(invoiceId) + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices that have no usage + * fees. If the invoice is configured to sync to an external provider, a successful response + * from this endpoint guarantees the invoice is present in the provider. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun synchronous(): Optional = body.synchronous() + + /** + * Returns the raw JSON value of [synchronous]. + * + * Unlike [synchronous], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _synchronous(): JsonField = body._synchronous() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InvoiceIssueSummaryParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [InvoiceIssueSummaryParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvoiceIssueSummaryParams]. */ + class Builder internal constructor() { + + private var invoiceId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(invoiceIssueSummaryParams: InvoiceIssueSummaryParams) = apply { + invoiceId = invoiceIssueSummaryParams.invoiceId + body = invoiceIssueSummaryParams.body.toBuilder() + additionalHeaders = invoiceIssueSummaryParams.additionalHeaders.toBuilder() + additionalQueryParams = invoiceIssueSummaryParams.additionalQueryParams.toBuilder() + } + + 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. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [synchronous] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices that have no usage + * fees. If the invoice is configured to sync to an external provider, a successful response + * from this endpoint guarantees the invoice is present in the provider. + */ + fun synchronous(synchronous: Boolean) = apply { body.synchronous(synchronous) } + + /** + * Sets [Builder.synchronous] to an arbitrary JSON value. + * + * You should usually call [Builder.synchronous] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun synchronous(synchronous: JsonField) = apply { body.synchronous(synchronous) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InvoiceIssueSummaryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InvoiceIssueSummaryParams = + InvoiceIssueSummaryParams( + invoiceId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> invoiceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val synchronous: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("synchronous") + @ExcludeMissing + synchronous: JsonField = JsonMissing.of() + ) : this(synchronous, mutableMapOf()) + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices that have no usage + * fees. If the invoice is configured to sync to an external provider, a successful response + * from this endpoint guarantees the invoice is present in the provider. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun synchronous(): Optional = synchronous.getOptional("synchronous") + + /** + * Returns the raw JSON value of [synchronous]. + * + * Unlike [synchronous], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("synchronous") + @ExcludeMissing + fun _synchronous(): JsonField = synchronous + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var synchronous: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + synchronous = body.synchronous + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be + * issued asynchronously. The synchronous option is only available for invoices that + * have no usage fees. If the invoice is configured to sync to an external provider, a + * successful response from this endpoint guarantees the invoice is present in the + * provider. + */ + fun synchronous(synchronous: Boolean) = synchronous(JsonField.of(synchronous)) + + /** + * Sets [Builder.synchronous] to an arbitrary JSON value. + * + * You should usually call [Builder.synchronous] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun synchronous(synchronous: JsonField) = apply { + this.synchronous = synchronous + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(synchronous, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + synchronous() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (synchronous.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + synchronous == other.synchronous && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(synchronous, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{synchronous=$synchronous, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceIssueSummaryParams && + invoiceId == other.invoiceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InvoiceIssueSummaryParams{invoiceId=$invoiceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt new file mode 100644 index 000000000..19139de54 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponse.kt @@ -0,0 +1,4704 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** #InvoiceApiResourceWithoutLineItems */ +class InvoiceIssueSummaryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val amountDue: JsonField, + private val autoCollection: JsonField, + private val billingAddress: JsonField
, + private val createdAt: JsonField, + private val creditNotes: JsonField>, + private val currency: JsonField, + private val customer: JsonField, + private val customerBalanceTransactions: JsonField>, + private val customerTaxId: JsonField, + private val dueDate: JsonField, + private val eligibleToIssueAt: JsonField, + private val hostedInvoiceUrl: JsonField, + private val invoiceDate: JsonField, + private val invoiceNumber: JsonField, + private val invoicePdf: JsonField, + private val invoiceSource: JsonField, + private val issueFailedAt: JsonField, + private val issuedAt: JsonField, + private val memo: JsonField, + private val metadata: JsonField, + private val paidAt: JsonField, + private val paymentAttempts: JsonField>, + private val paymentFailedAt: JsonField, + private val paymentStartedAt: JsonField, + private val scheduledIssueAt: JsonField, + private val shippingAddress: JsonField
, + private val status: JsonField, + private val subscription: JsonField, + private val syncFailedAt: JsonField, + private val total: JsonField, + private val voidedAt: JsonField, + private val willAutoIssue: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount_due") @ExcludeMissing amountDue: JsonField = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + billingAddress: JsonField
= JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_notes") + @ExcludeMissing + creditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + customer: JsonField = JsonMissing.of(), + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + customerBalanceTransactions: JsonField> = JsonMissing.of(), + @JsonProperty("customer_tax_id") + @ExcludeMissing + customerTaxId: JsonField = JsonMissing.of(), + @JsonProperty("due_date") + @ExcludeMissing + dueDate: JsonField = JsonMissing.of(), + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + eligibleToIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + hostedInvoiceUrl: JsonField = JsonMissing.of(), + @JsonProperty("invoice_date") + @ExcludeMissing + invoiceDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_number") + @ExcludeMissing + invoiceNumber: JsonField = JsonMissing.of(), + @JsonProperty("invoice_pdf") + @ExcludeMissing + invoicePdf: JsonField = JsonMissing.of(), + @JsonProperty("invoice_source") + @ExcludeMissing + invoiceSource: JsonField = JsonMissing.of(), + @JsonProperty("issue_failed_at") + @ExcludeMissing + issueFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("issued_at") + @ExcludeMissing + issuedAt: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("paid_at") + @ExcludeMissing + paidAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_attempts") + @ExcludeMissing + paymentAttempts: JsonField> = JsonMissing.of(), + @JsonProperty("payment_failed_at") + @ExcludeMissing + paymentFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_started_at") + @ExcludeMissing + paymentStartedAt: JsonField = JsonMissing.of(), + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + scheduledIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + shippingAddress: JsonField
= JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + subscription: JsonField = JsonMissing.of(), + @JsonProperty("sync_failed_at") + @ExcludeMissing + syncFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + voidedAt: JsonField = JsonMissing.of(), + @JsonProperty("will_auto_issue") + @ExcludeMissing + willAutoIssue: JsonField = JsonMissing.of(), + ) : this( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceDate, + invoiceNumber, + invoicePdf, + invoiceSource, + issueFailedAt, + issuedAt, + memo, + metadata, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + syncFailedAt, + total, + voidedAt, + willAutoIssue, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * This is the final amount required to be charged to the customer and reflects the application + * of the customer balance to the `total` of the invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun amountDue(): String = amountDue.getRequired("amount_due") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun autoCollection(): AutoCollection = autoCollection.getRequired("auto_collection") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun billingAddress(): Optional
= billingAddress.getOptional("billing_address") + + /** + * The creation time of the resource in Orb. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * A list of credit notes associated with the invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditNotes(): List = creditNotes.getRequired("credit_notes") + + /** + * An ISO 4217 currency string or `credits` + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun customer(): CustomerMinified = customer.getRequired("customer") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun customerBalanceTransactions(): List = + customerBalanceTransactions.getRequired("customer_balance_transactions") + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to the + * headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |----------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Albania |`al_tin` |Albania Tax Identification Number | + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Angola |`ao_tin` |Angola Tax Identification Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Armenia |`am_tin` |Armenia Tax Identification Number | + * |Aruba |`aw_tin` |Aruba Tax Identification Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Azerbaijan |`az_tin` |Azerbaijan Tax Identification Number | + * |Bahamas |`bs_tin` |Bahamas Tax Identification Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Bangladesh |`bd_bin` |Bangladesh Business Identification Number | + * |Barbados |`bb_tin` |Barbados Tax Identification Number | + * |Belarus |`by_tin` |Belarus TIN Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Benin |`bj_ifu` |Benin Tax Identification Number (Identifiant Fiscal Unique) | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Bosnia and Herzegovina|`ba_tin` |Bosnia and Herzegovina Tax Identification Number | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Burkina Faso |`bf_ifu` |Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) | + * |Cambodia |`kh_tin` |Cambodia Tax Identification Number | + * |Cameroon |`cm_niu` |Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (Québec) | + * |Cape Verde |`cv_nif` |Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Congo-Kinshasa |`cd_nif` |Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Croatia |`hr_oib` |Croatian Personal Identification Number (OIB) | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | + * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`de_stn` |German Tax Number (Steuernummer) | + * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | + * |Greece |`eu_vat` |European VAT Number | + * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | + * |Laos |`la_tin` |Laos Tax Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Liechtenstein |`li_vat` |Liechtenstein VAT Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat` |European VAT Number | + * |Mauritania |`mr_nif` |Mauritania Tax Identification Number (Número de Identificação Fiscal) | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Moldova |`md_vat` |Moldova VAT Number | + * |Montenegro |`me_pib` |Montenegro PIB Number | + * |Morocco |`ma_vat` |Morocco VAT Number | + * |Nepal |`np_pan` |Nepal PAN Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |North Macedonia |`mk_vat` |North Macedonia VAT Number | + * |Northern Ireland |`eu_vat` |Northern Ireland VAT Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Senegal |`sn_ninea` |Senegal NINEA Number | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna številka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | + * |Suriname |`sr_fin` |Suriname FIN Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_uid` |Switzerland UID Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Tajikistan |`tj_tin` |Tajikistan Tax Identification Number | + * |Tanzania |`tz_vat` |Tanzania VAT Number | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Uganda |`ug_tin` |Uganda Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates |`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Uzbekistan |`uz_tin` |Uzbekistan TIN Number | + * |Uzbekistan |`uz_vat` |Uzbekistan VAT Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * |Zambia |`zm_tin` |Zambia Tax Identification Number | + * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun customerTaxId(): Optional = customerTaxId.getOptional("customer_tax_id") + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet finalized. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun dueDate(): Optional = dueDate.getOptional("due_date") + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice will be + * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice will + * automatically begin issuing at this time. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun eligibleToIssueAt(): Optional = + eligibleToIssueAt.getOptional("eligible_to_issue_at") + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the invoice's + * due date, or 60 days after being re-generated through the UI. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun hostedInvoiceUrl(): Optional = hostedInvoiceUrl.getOptional("hosted_invoice_url") + + /** + * The scheduled date of the invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceDate(): OffsetDateTime = invoiceDate.getRequired("invoice_date") + + /** + * Automatically generated invoice number to help track and reconcile invoices. Invoice numbers + * have a prefix such as `RFOBWG`. These can be sequential per account or customer. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceNumber(): String = invoiceNumber.getRequired("invoice_number") + + /** + * The link to download the PDF representation of the `Invoice`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun invoicePdf(): Optional = invoicePdf.getOptional("invoice_pdf") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun invoiceSource(): InvoiceSource = invoiceSource.getRequired("invoice_source") + + /** + * If the invoice failed to issue, this will be the last time it failed to issue (even if it is + * now in a different state.) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun issueFailedAt(): Optional = issueFailedAt.getOptional("issue_failed_at") + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` (even if it + * is now in a different state.) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun issuedAt(): Optional = issuedAt.getOptional("issued_at") + + /** + * Free-form text which is available on the invoice PDF and the Orb invoice portal. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun memo(): Optional = memo.getOptional("memo") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paidAt(): Optional = paidAt.getOptional("paid_at") + + /** + * A list of payment attempts associated with the invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paymentAttempts(): List = paymentAttempts.getRequired("payment_attempts") + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most recent + * attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentFailedAt(): Optional = + paymentFailedAt.getOptional("payment_failed_at") + + /** + * If payment was attempted on this invoice, this will be the start time of the most recent + * attempt. This field is especially useful for delayed-notification payment mechanisms (like + * bank transfers), where payment can take 3 days or more. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun paymentStartedAt(): Optional = + paymentStartedAt.getOptional("payment_started_at") + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be + * issued. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun scheduledIssueAt(): Optional = + scheduledIssueAt.getOptional("scheduled_issue_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun shippingAddress(): Optional
= shippingAddress.getOptional("shipping_address") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun subscription(): Optional = subscription.getOptional("subscription") + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider sync + * was attempted. This field will always be `null` for invoices using Orb Invoicing. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun syncFailedAt(): Optional = syncFailedAt.getOptional("sync_failed_at") + + /** + * The total after any minimums and discounts have been applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun total(): String = total.getRequired("total") + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was voided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun voidedAt(): Optional = voidedAt.getOptional("voided_at") + + /** + * This is true if the invoice will be automatically issued in the future, and false otherwise. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun willAutoIssue(): Boolean = willAutoIssue.getRequired("will_auto_issue") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [amountDue]. + * + * Unlike [amountDue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue(): JsonField = amountDue + + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * Returns the raw JSON value of [billingAddress]. + * + * Unlike [billingAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField
= billingAddress + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditNotes]. + * + * Unlike [creditNotes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_notes") + @ExcludeMissing + fun _creditNotes(): JsonField> = creditNotes + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [customer]. + * + * Unlike [customer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + /** + * Returns the raw JSON value of [customerBalanceTransactions]. + * + * Unlike [customerBalanceTransactions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + fun _customerBalanceTransactions(): JsonField> = + customerBalanceTransactions + + /** + * Returns the raw JSON value of [customerTaxId]. + * + * Unlike [customerTaxId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_tax_id") + @ExcludeMissing + fun _customerTaxId(): JsonField = customerTaxId + + /** + * Returns the raw JSON value of [dueDate]. + * + * Unlike [dueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = dueDate + + /** + * Returns the raw JSON value of [eligibleToIssueAt]. + * + * Unlike [eligibleToIssueAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + fun _eligibleToIssueAt(): JsonField = eligibleToIssueAt + + /** + * Returns the raw JSON value of [hostedInvoiceUrl]. + * + * Unlike [hostedInvoiceUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + fun _hostedInvoiceUrl(): JsonField = hostedInvoiceUrl + + /** + * Returns the raw JSON value of [invoiceDate]. + * + * Unlike [invoiceDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_date") + @ExcludeMissing + fun _invoiceDate(): JsonField = invoiceDate + + /** + * Returns the raw JSON value of [invoiceNumber]. + * + * Unlike [invoiceNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber + + /** + * Returns the raw JSON value of [invoicePdf]. + * + * Unlike [invoicePdf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_pdf") @ExcludeMissing fun _invoicePdf(): JsonField = invoicePdf + + /** + * Returns the raw JSON value of [invoiceSource]. + * + * Unlike [invoiceSource], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_source") + @ExcludeMissing + fun _invoiceSource(): JsonField = invoiceSource + + /** + * Returns the raw JSON value of [issueFailedAt]. + * + * Unlike [issueFailedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issue_failed_at") + @ExcludeMissing + fun _issueFailedAt(): JsonField = issueFailedAt + + /** + * Returns the raw JSON value of [issuedAt]. + * + * Unlike [issuedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issued_at") @ExcludeMissing fun _issuedAt(): JsonField = issuedAt + + /** + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [paidAt]. + * + * Unlike [paidAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paid_at") @ExcludeMissing fun _paidAt(): JsonField = paidAt + + /** + * Returns the raw JSON value of [paymentAttempts]. + * + * Unlike [paymentAttempts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_attempts") + @ExcludeMissing + fun _paymentAttempts(): JsonField> = paymentAttempts + + /** + * Returns the raw JSON value of [paymentFailedAt]. + * + * Unlike [paymentFailedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_failed_at") + @ExcludeMissing + fun _paymentFailedAt(): JsonField = paymentFailedAt + + /** + * Returns the raw JSON value of [paymentStartedAt]. + * + * Unlike [paymentStartedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_started_at") + @ExcludeMissing + fun _paymentStartedAt(): JsonField = paymentStartedAt + + /** + * Returns the raw JSON value of [scheduledIssueAt]. + * + * Unlike [scheduledIssueAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + fun _scheduledIssueAt(): JsonField = scheduledIssueAt + + /** + * Returns the raw JSON value of [shippingAddress]. + * + * Unlike [shippingAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField
= shippingAddress + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscription]. + * + * Unlike [subscription], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + /** + * Returns the raw JSON value of [syncFailedAt]. + * + * Unlike [syncFailedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sync_failed_at") + @ExcludeMissing + fun _syncFailedAt(): JsonField = syncFailedAt + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** + * Returns the raw JSON value of [voidedAt]. + * + * Unlike [voidedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt(): JsonField = voidedAt + + /** + * Returns the raw JSON value of [willAutoIssue]. + * + * Unlike [willAutoIssue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("will_auto_issue") + @ExcludeMissing + fun _willAutoIssue(): JsonField = willAutoIssue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InvoiceIssueSummaryResponse]. + * + * The following fields are required: + * ```java + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .issueFailedAt() + * .issuedAt() + * .memo() + * .metadata() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvoiceIssueSummaryResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amountDue: JsonField? = null + private var autoCollection: JsonField? = null + private var billingAddress: JsonField
? = null + private var createdAt: JsonField? = null + private var creditNotes: JsonField>? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var customerBalanceTransactions: + JsonField>? = + null + private var customerTaxId: JsonField? = null + private var dueDate: JsonField? = null + private var eligibleToIssueAt: JsonField? = null + private var hostedInvoiceUrl: JsonField? = null + private var invoiceDate: JsonField? = null + private var invoiceNumber: JsonField? = null + private var invoicePdf: JsonField? = null + private var invoiceSource: JsonField? = null + private var issueFailedAt: JsonField? = null + private var issuedAt: JsonField? = null + private var memo: JsonField? = null + private var metadata: JsonField? = null + private var paidAt: JsonField? = null + private var paymentAttempts: JsonField>? = null + private var paymentFailedAt: JsonField? = null + private var paymentStartedAt: JsonField? = null + private var scheduledIssueAt: JsonField? = null + private var shippingAddress: JsonField
? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var syncFailedAt: JsonField? = null + private var total: JsonField? = null + private var voidedAt: JsonField? = null + private var willAutoIssue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoiceIssueSummaryResponse: InvoiceIssueSummaryResponse) = apply { + id = invoiceIssueSummaryResponse.id + amountDue = invoiceIssueSummaryResponse.amountDue + autoCollection = invoiceIssueSummaryResponse.autoCollection + billingAddress = invoiceIssueSummaryResponse.billingAddress + createdAt = invoiceIssueSummaryResponse.createdAt + creditNotes = invoiceIssueSummaryResponse.creditNotes.map { it.toMutableList() } + currency = invoiceIssueSummaryResponse.currency + customer = invoiceIssueSummaryResponse.customer + customerBalanceTransactions = + invoiceIssueSummaryResponse.customerBalanceTransactions.map { it.toMutableList() } + customerTaxId = invoiceIssueSummaryResponse.customerTaxId + dueDate = invoiceIssueSummaryResponse.dueDate + eligibleToIssueAt = invoiceIssueSummaryResponse.eligibleToIssueAt + hostedInvoiceUrl = invoiceIssueSummaryResponse.hostedInvoiceUrl + invoiceDate = invoiceIssueSummaryResponse.invoiceDate + invoiceNumber = invoiceIssueSummaryResponse.invoiceNumber + invoicePdf = invoiceIssueSummaryResponse.invoicePdf + invoiceSource = invoiceIssueSummaryResponse.invoiceSource + issueFailedAt = invoiceIssueSummaryResponse.issueFailedAt + issuedAt = invoiceIssueSummaryResponse.issuedAt + memo = invoiceIssueSummaryResponse.memo + metadata = invoiceIssueSummaryResponse.metadata + paidAt = invoiceIssueSummaryResponse.paidAt + paymentAttempts = invoiceIssueSummaryResponse.paymentAttempts.map { it.toMutableList() } + paymentFailedAt = invoiceIssueSummaryResponse.paymentFailedAt + paymentStartedAt = invoiceIssueSummaryResponse.paymentStartedAt + scheduledIssueAt = invoiceIssueSummaryResponse.scheduledIssueAt + shippingAddress = invoiceIssueSummaryResponse.shippingAddress + status = invoiceIssueSummaryResponse.status + subscription = invoiceIssueSummaryResponse.subscription + syncFailedAt = invoiceIssueSummaryResponse.syncFailedAt + total = invoiceIssueSummaryResponse.total + voidedAt = invoiceIssueSummaryResponse.voidedAt + willAutoIssue = invoiceIssueSummaryResponse.willAutoIssue + additionalProperties = invoiceIssueSummaryResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * This is the final amount required to be charged to the customer and reflects the + * application of the customer balance to the `total` of the invoice. + */ + fun amountDue(amountDue: String) = amountDue(JsonField.of(amountDue)) + + /** + * Sets [Builder.amountDue] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDue] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amountDue(amountDue: JsonField) = apply { this.amountDue = amountDue } + + fun autoCollection(autoCollection: AutoCollection) = + autoCollection(JsonField.of(autoCollection)) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [AutoCollection] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingAddress(billingAddress: Address?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + /** Alias for calling [Builder.billingAddress] with `billingAddress.orElse(null)`. */ + fun billingAddress(billingAddress: Optional
) = + billingAddress(billingAddress.getOrNull()) + + /** + * Sets [Builder.billingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.billingAddress] with a well-typed [Address] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingAddress(billingAddress: JsonField
) = apply { + this.billingAddress = billingAddress + } + + /** The creation time of the resource in Orb. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** A list of credit notes associated with the invoice */ + fun creditNotes(creditNotes: List) = creditNotes(JsonField.of(creditNotes)) + + /** + * Sets [Builder.creditNotes] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNotes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditNotes(creditNotes: JsonField>) = apply { + this.creditNotes = creditNotes.map { it.toMutableList() } + } + + /** + * Adds a single [CreditNote] to [creditNotes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCreditNote(creditNote: CreditNote) = apply { + creditNotes = + (creditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("creditNotes", it).add(creditNote) + } + } + + /** An ISO 4217 currency string or `credits` */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun customer(customer: CustomerMinified) = customer(JsonField.of(customer)) + + /** + * Sets [Builder.customer] to an arbitrary JSON value. + * + * You should usually call [Builder.customer] with a well-typed [CustomerMinified] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customer(customer: JsonField) = apply { this.customer = customer } + + fun customerBalanceTransactions( + customerBalanceTransactions: List + ) = customerBalanceTransactions(JsonField.of(customerBalanceTransactions)) + + /** + * Sets [Builder.customerBalanceTransactions] to an arbitrary JSON value. + * + * You should usually call [Builder.customerBalanceTransactions] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun customerBalanceTransactions( + customerBalanceTransactions: JsonField> + ) = apply { + this.customerBalanceTransactions = + customerBalanceTransactions.map { it.toMutableList() } + } + + /** + * Adds a single [CustomerBalanceTransaction] to [customerBalanceTransactions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomerBalanceTransaction(customerBalanceTransaction: CustomerBalanceTransaction) = + apply { + customerBalanceTransactions = + (customerBalanceTransactions ?: JsonField.of(mutableListOf())).also { + checkKnown("customerBalanceTransactions", it) + .add(customerBalanceTransaction) + } + } + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |----------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Albania |`al_tin` |Albania Tax Identification Number | + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Angola |`ao_tin` |Angola Tax Identification Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Armenia |`am_tin` |Armenia Tax Identification Number | + * |Aruba |`aw_tin` |Aruba Tax Identification Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Azerbaijan |`az_tin` |Azerbaijan Tax Identification Number | + * |Bahamas |`bs_tin` |Bahamas Tax Identification Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Bangladesh |`bd_bin` |Bangladesh Business Identification Number | + * |Barbados |`bb_tin` |Barbados Tax Identification Number | + * |Belarus |`by_tin` |Belarus TIN Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Benin |`bj_ifu` |Benin Tax Identification Number (Identifiant Fiscal Unique) | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Bosnia and Herzegovina|`ba_tin` |Bosnia and Herzegovina Tax Identification Number | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Burkina Faso |`bf_ifu` |Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) | + * |Cambodia |`kh_tin` |Cambodia Tax Identification Number | + * |Cameroon |`cm_niu` |Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (Québec) | + * |Cape Verde |`cv_nif` |Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Congo-Kinshasa |`cd_nif` |Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Croatia |`hr_oib` |Croatian Personal Identification Number (OIB) | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | + * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`de_stn` |German Tax Number (Steuernummer) | + * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | + * |Greece |`eu_vat` |European VAT Number | + * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | + * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Kyrgyzstan |`kg_tin` |Kyrgyzstan Tax Identification Number | + * |Laos |`la_tin` |Laos Tax Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Liechtenstein |`li_vat` |Liechtenstein VAT Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat` |European VAT Number | + * |Mauritania |`mr_nif` |Mauritania Tax Identification Number (Número de Identificação Fiscal) | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Moldova |`md_vat` |Moldova VAT Number | + * |Montenegro |`me_pib` |Montenegro PIB Number | + * |Morocco |`ma_vat` |Morocco VAT Number | + * |Nepal |`np_pan` |Nepal PAN Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |North Macedonia |`mk_vat` |North Macedonia VAT Number | + * |Northern Ireland |`eu_vat` |Northern Ireland VAT Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Senegal |`sn_ninea` |Senegal NINEA Number | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna številka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | + * |Suriname |`sr_fin` |Suriname FIN Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_uid` |Switzerland UID Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Tajikistan |`tj_tin` |Tajikistan Tax Identification Number | + * |Tanzania |`tz_vat` |Tanzania VAT Number | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Uganda |`ug_tin` |Uganda Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates |`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Uzbekistan |`uz_tin` |Uzbekistan TIN Number | + * |Uzbekistan |`uz_vat` |Uzbekistan VAT Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * |Zambia |`zm_tin` |Zambia Tax Identification Number | + * |Zimbabwe |`zw_tin` |Zimbabwe Tax Identification Number | + */ + fun customerTaxId(customerTaxId: CustomerTaxId?) = + customerTaxId(JsonField.ofNullable(customerTaxId)) + + /** Alias for calling [Builder.customerTaxId] with `customerTaxId.orElse(null)`. */ + fun customerTaxId(customerTaxId: Optional) = + customerTaxId(customerTaxId.getOrNull()) + + /** + * Sets [Builder.customerTaxId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerTaxId] with a well-typed [CustomerTaxId] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerTaxId(customerTaxId: JsonField) = apply { + this.customerTaxId = customerTaxId + } + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. + */ + fun dueDate(dueDate: OffsetDateTime?) = dueDate(JsonField.ofNullable(dueDate)) + + /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ + fun dueDate(dueDate: Optional) = dueDate(dueDate.getOrNull()) + + /** + * Sets [Builder.dueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.dueDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice will be + * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice + * will automatically begin issuing at this time. + */ + fun eligibleToIssueAt(eligibleToIssueAt: OffsetDateTime?) = + eligibleToIssueAt(JsonField.ofNullable(eligibleToIssueAt)) + + /** Alias for calling [Builder.eligibleToIssueAt] with `eligibleToIssueAt.orElse(null)`. */ + fun eligibleToIssueAt(eligibleToIssueAt: Optional) = + eligibleToIssueAt(eligibleToIssueAt.getOrNull()) + + /** + * Sets [Builder.eligibleToIssueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.eligibleToIssueAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun eligibleToIssueAt(eligibleToIssueAt: JsonField) = apply { + this.eligibleToIssueAt = eligibleToIssueAt + } + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the + * invoice's due date, or 60 days after being re-generated through the UI. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: String?) = + hostedInvoiceUrl(JsonField.ofNullable(hostedInvoiceUrl)) + + /** Alias for calling [Builder.hostedInvoiceUrl] with `hostedInvoiceUrl.orElse(null)`. */ + fun hostedInvoiceUrl(hostedInvoiceUrl: Optional) = + hostedInvoiceUrl(hostedInvoiceUrl.getOrNull()) + + /** + * Sets [Builder.hostedInvoiceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.hostedInvoiceUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: JsonField) = apply { + this.hostedInvoiceUrl = hostedInvoiceUrl + } + + /** The scheduled date of the invoice */ + fun invoiceDate(invoiceDate: OffsetDateTime) = invoiceDate(JsonField.of(invoiceDate)) + + /** + * Sets [Builder.invoiceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceDate(invoiceDate: JsonField) = apply { + this.invoiceDate = invoiceDate + } + + /** + * Automatically generated invoice number to help track and reconcile invoices. Invoice + * numbers have a prefix such as `RFOBWG`. These can be sequential per account or customer. + */ + fun invoiceNumber(invoiceNumber: String) = invoiceNumber(JsonField.of(invoiceNumber)) + + /** + * Sets [Builder.invoiceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoiceNumber(invoiceNumber: JsonField) = apply { + this.invoiceNumber = invoiceNumber + } + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(invoicePdf: String?) = invoicePdf(JsonField.ofNullable(invoicePdf)) + + /** Alias for calling [Builder.invoicePdf] with `invoicePdf.orElse(null)`. */ + fun invoicePdf(invoicePdf: Optional) = invoicePdf(invoicePdf.getOrNull()) + + /** + * Sets [Builder.invoicePdf] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicePdf] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicePdf(invoicePdf: JsonField) = apply { this.invoicePdf = invoicePdf } + + fun invoiceSource(invoiceSource: InvoiceSource) = invoiceSource(JsonField.of(invoiceSource)) + + /** + * Sets [Builder.invoiceSource] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceSource] with a well-typed [InvoiceSource] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceSource(invoiceSource: JsonField) = apply { + this.invoiceSource = invoiceSource + } + + /** + * If the invoice failed to issue, this will be the last time it failed to issue (even if it + * is now in a different state.) + */ + fun issueFailedAt(issueFailedAt: OffsetDateTime?) = + issueFailedAt(JsonField.ofNullable(issueFailedAt)) + + /** Alias for calling [Builder.issueFailedAt] with `issueFailedAt.orElse(null)`. */ + fun issueFailedAt(issueFailedAt: Optional) = + issueFailedAt(issueFailedAt.getOrNull()) + + /** + * Sets [Builder.issueFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issueFailedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issueFailedAt(issueFailedAt: JsonField) = apply { + this.issueFailedAt = issueFailedAt + } + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` (even + * if it is now in a different state.) + */ + fun issuedAt(issuedAt: OffsetDateTime?) = issuedAt(JsonField.ofNullable(issuedAt)) + + /** Alias for calling [Builder.issuedAt] with `issuedAt.orElse(null)`. */ + fun issuedAt(issuedAt: Optional) = issuedAt(issuedAt.getOrNull()) + + /** + * Sets [Builder.issuedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issuedAt(issuedAt: JsonField) = apply { this.issuedAt = issuedAt } + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** Alias for calling [Builder.memo] with `memo.orElse(null)`. */ + fun memo(memo: Optional) = memo(memo.getOrNull()) + + /** + * Sets [Builder.memo] to an arbitrary JSON value. + * + * You should usually call [Builder.memo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + */ + fun paidAt(paidAt: OffsetDateTime?) = paidAt(JsonField.ofNullable(paidAt)) + + /** Alias for calling [Builder.paidAt] with `paidAt.orElse(null)`. */ + fun paidAt(paidAt: Optional) = paidAt(paidAt.getOrNull()) + + /** + * Sets [Builder.paidAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paidAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paidAt(paidAt: JsonField) = apply { this.paidAt = paidAt } + + /** A list of payment attempts associated with the invoice */ + fun paymentAttempts(paymentAttempts: List) = + paymentAttempts(JsonField.of(paymentAttempts)) + + /** + * Sets [Builder.paymentAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentAttempts] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun paymentAttempts(paymentAttempts: JsonField>) = apply { + this.paymentAttempts = paymentAttempts.map { it.toMutableList() } + } + + /** + * Adds a single [PaymentAttempt] to [paymentAttempts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPaymentAttempt(paymentAttempt: PaymentAttempt) = apply { + paymentAttempts = + (paymentAttempts ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentAttempts", it).add(paymentAttempt) + } + } + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most + * recent attempt. + */ + fun paymentFailedAt(paymentFailedAt: OffsetDateTime?) = + paymentFailedAt(JsonField.ofNullable(paymentFailedAt)) + + /** Alias for calling [Builder.paymentFailedAt] with `paymentFailedAt.orElse(null)`. */ + fun paymentFailedAt(paymentFailedAt: Optional) = + paymentFailedAt(paymentFailedAt.getOrNull()) + + /** + * Sets [Builder.paymentFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentFailedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun paymentFailedAt(paymentFailedAt: JsonField) = apply { + this.paymentFailedAt = paymentFailedAt + } + + /** + * If payment was attempted on this invoice, this will be the start time of the most recent + * attempt. This field is especially useful for delayed-notification payment mechanisms + * (like bank transfers), where payment can take 3 days or more. + */ + fun paymentStartedAt(paymentStartedAt: OffsetDateTime?) = + paymentStartedAt(JsonField.ofNullable(paymentStartedAt)) + + /** Alias for calling [Builder.paymentStartedAt] with `paymentStartedAt.orElse(null)`. */ + fun paymentStartedAt(paymentStartedAt: Optional) = + paymentStartedAt(paymentStartedAt.getOrNull()) + + /** + * Sets [Builder.paymentStartedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentStartedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun paymentStartedAt(paymentStartedAt: JsonField) = apply { + this.paymentStartedAt = paymentStartedAt + } + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to + * be issued. + */ + fun scheduledIssueAt(scheduledIssueAt: OffsetDateTime?) = + scheduledIssueAt(JsonField.ofNullable(scheduledIssueAt)) + + /** Alias for calling [Builder.scheduledIssueAt] with `scheduledIssueAt.orElse(null)`. */ + fun scheduledIssueAt(scheduledIssueAt: Optional) = + scheduledIssueAt(scheduledIssueAt.getOrNull()) + + /** + * Sets [Builder.scheduledIssueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.scheduledIssueAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scheduledIssueAt(scheduledIssueAt: JsonField) = apply { + this.scheduledIssueAt = scheduledIssueAt + } + + fun shippingAddress(shippingAddress: Address?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + /** Alias for calling [Builder.shippingAddress] with `shippingAddress.orElse(null)`. */ + fun shippingAddress(shippingAddress: Optional
) = + shippingAddress(shippingAddress.getOrNull()) + + /** + * Sets [Builder.shippingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingAddress] with a well-typed [Address] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shippingAddress(shippingAddress: JsonField
) = apply { + this.shippingAddress = shippingAddress + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: SubscriptionMinified?) = + subscription(JsonField.ofNullable(subscription)) + + /** Alias for calling [Builder.subscription] with `subscription.orElse(null)`. */ + fun subscription(subscription: Optional) = + subscription(subscription.getOrNull()) + + /** + * Sets [Builder.subscription] to an arbitrary JSON value. + * + * You should usually call [Builder.subscription] with a well-typed [SubscriptionMinified] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider + * sync was attempted. This field will always be `null` for invoices using Orb Invoicing. + */ + fun syncFailedAt(syncFailedAt: OffsetDateTime?) = + syncFailedAt(JsonField.ofNullable(syncFailedAt)) + + /** Alias for calling [Builder.syncFailedAt] with `syncFailedAt.orElse(null)`. */ + fun syncFailedAt(syncFailedAt: Optional) = + syncFailedAt(syncFailedAt.getOrNull()) + + /** + * Sets [Builder.syncFailedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.syncFailedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun syncFailedAt(syncFailedAt: JsonField) = apply { + this.syncFailedAt = syncFailedAt + } + + /** The total after any minimums and discounts have been applied. */ + fun total(total: String) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was + * voided. + */ + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** Alias for calling [Builder.voidedAt] with `voidedAt.orElse(null)`. */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.getOrNull()) + + /** + * Sets [Builder.voidedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } + + /** + * This is true if the invoice will be automatically issued in the future, and false + * otherwise. + */ + fun willAutoIssue(willAutoIssue: Boolean) = willAutoIssue(JsonField.of(willAutoIssue)) + + /** + * Sets [Builder.willAutoIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.willAutoIssue] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun willAutoIssue(willAutoIssue: JsonField) = apply { + this.willAutoIssue = willAutoIssue + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InvoiceIssueSummaryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .issueFailedAt() + * .issuedAt() + * .memo() + * .metadata() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvoiceIssueSummaryResponse = + InvoiceIssueSummaryResponse( + checkRequired("id", id), + checkRequired("amountDue", amountDue), + checkRequired("autoCollection", autoCollection), + checkRequired("billingAddress", billingAddress), + checkRequired("createdAt", createdAt), + checkRequired("creditNotes", creditNotes).map { it.toImmutable() }, + checkRequired("currency", currency), + checkRequired("customer", customer), + checkRequired("customerBalanceTransactions", customerBalanceTransactions).map { + it.toImmutable() + }, + checkRequired("customerTaxId", customerTaxId), + checkRequired("dueDate", dueDate), + checkRequired("eligibleToIssueAt", eligibleToIssueAt), + checkRequired("hostedInvoiceUrl", hostedInvoiceUrl), + checkRequired("invoiceDate", invoiceDate), + checkRequired("invoiceNumber", invoiceNumber), + checkRequired("invoicePdf", invoicePdf), + checkRequired("invoiceSource", invoiceSource), + checkRequired("issueFailedAt", issueFailedAt), + checkRequired("issuedAt", issuedAt), + checkRequired("memo", memo), + checkRequired("metadata", metadata), + checkRequired("paidAt", paidAt), + checkRequired("paymentAttempts", paymentAttempts).map { it.toImmutable() }, + checkRequired("paymentFailedAt", paymentFailedAt), + checkRequired("paymentStartedAt", paymentStartedAt), + checkRequired("scheduledIssueAt", scheduledIssueAt), + checkRequired("shippingAddress", shippingAddress), + checkRequired("status", status), + checkRequired("subscription", subscription), + checkRequired("syncFailedAt", syncFailedAt), + checkRequired("total", total), + checkRequired("voidedAt", voidedAt), + checkRequired("willAutoIssue", willAutoIssue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): InvoiceIssueSummaryResponse = apply { + if (validated) { + return@apply + } + + id() + amountDue() + autoCollection().validate() + billingAddress().ifPresent { it.validate() } + createdAt() + creditNotes().forEach { it.validate() } + currency() + customer().validate() + customerBalanceTransactions().forEach { it.validate() } + customerTaxId().ifPresent { it.validate() } + dueDate() + eligibleToIssueAt() + hostedInvoiceUrl() + invoiceDate() + invoiceNumber() + invoicePdf() + invoiceSource().validate() + issueFailedAt() + issuedAt() + memo() + metadata().validate() + paidAt() + paymentAttempts().forEach { it.validate() } + paymentFailedAt() + paymentStartedAt() + scheduledIssueAt() + shippingAddress().ifPresent { it.validate() } + status().validate() + subscription().ifPresent { it.validate() } + syncFailedAt() + total() + voidedAt() + willAutoIssue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amountDue.asKnown().isPresent) 1 else 0) + + (autoCollection.asKnown().getOrNull()?.validity() ?: 0) + + (billingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNotes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (customer.asKnown().getOrNull()?.validity() ?: 0) + + (customerBalanceTransactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (customerTaxId.asKnown().getOrNull()?.validity() ?: 0) + + (if (dueDate.asKnown().isPresent) 1 else 0) + + (if (eligibleToIssueAt.asKnown().isPresent) 1 else 0) + + (if (hostedInvoiceUrl.asKnown().isPresent) 1 else 0) + + (if (invoiceDate.asKnown().isPresent) 1 else 0) + + (if (invoiceNumber.asKnown().isPresent) 1 else 0) + + (if (invoicePdf.asKnown().isPresent) 1 else 0) + + (invoiceSource.asKnown().getOrNull()?.validity() ?: 0) + + (if (issueFailedAt.asKnown().isPresent) 1 else 0) + + (if (issuedAt.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (paidAt.asKnown().isPresent) 1 else 0) + + (paymentAttempts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (paymentFailedAt.asKnown().isPresent) 1 else 0) + + (if (paymentStartedAt.asKnown().isPresent) 1 else 0) + + (if (scheduledIssueAt.asKnown().isPresent) 1 else 0) + + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (subscription.asKnown().getOrNull()?.validity() ?: 0) + + (if (syncFailedAt.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + + (if (willAutoIssue.asKnown().isPresent) 1 else 0) + + class AutoCollection + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val enabled: JsonField, + private val nextAttemptAt: JsonField, + private val numAttempts: JsonField, + private val previouslyAttemptedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("next_attempt_at") + @ExcludeMissing + nextAttemptAt: JsonField = JsonMissing.of(), + @JsonProperty("num_attempts") + @ExcludeMissing + numAttempts: JsonField = JsonMissing.of(), + @JsonProperty("previously_attempted_at") + @ExcludeMissing + previouslyAttemptedAt: JsonField = JsonMissing.of(), + ) : this(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, mutableMapOf()) + + /** + * True only if auto-collection is enabled for this invoice. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabled(): Optional = enabled.getOptional("enabled") + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when the next + * attempt will occur. If dunning has been exhausted, or auto-collection is not enabled for + * this invoice, this field will be `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextAttemptAt(): Optional = nextAttemptAt.getOptional("next_attempt_at") + + /** + * Number of auto-collection payment attempts. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numAttempts(): Optional = numAttempts.getOptional("num_attempts") + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field will + * reflect when that attempt occurred. In conjunction with `next_attempt_at`, this can be + * used to tell whether the invoice is currently in dunning (that is, + * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or if + * dunning has been exhausted (`previously_attempted_at` is non-null, but + * `next_attempt_time` is null). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previouslyAttemptedAt(): Optional = + previouslyAttemptedAt.getOptional("previously_attempted_at") + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + + /** + * Returns the raw JSON value of [nextAttemptAt]. + * + * Unlike [nextAttemptAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("next_attempt_at") + @ExcludeMissing + fun _nextAttemptAt(): JsonField = nextAttemptAt + + /** + * Returns the raw JSON value of [numAttempts]. + * + * Unlike [numAttempts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_attempts") + @ExcludeMissing + fun _numAttempts(): JsonField = numAttempts + + /** + * Returns the raw JSON value of [previouslyAttemptedAt]. + * + * Unlike [previouslyAttemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previously_attempted_at") + @ExcludeMissing + fun _previouslyAttemptedAt(): JsonField = previouslyAttemptedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutoCollection]. + * + * The following fields are required: + * ```java + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoCollection]. */ + class Builder internal constructor() { + + private var enabled: JsonField? = null + private var nextAttemptAt: JsonField? = null + private var numAttempts: JsonField? = null + private var previouslyAttemptedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoCollection: AutoCollection) = apply { + enabled = autoCollection.enabled + nextAttemptAt = autoCollection.nextAttemptAt + numAttempts = autoCollection.numAttempts + previouslyAttemptedAt = autoCollection.previouslyAttemptedAt + additionalProperties = autoCollection.additionalProperties.toMutableMap() + } + + /** True only if auto-collection is enabled for this invoice. */ + fun enabled(enabled: Boolean?) = enabled(JsonField.ofNullable(enabled)) + + /** + * Alias for [Builder.enabled]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun enabled(enabled: Boolean) = enabled(enabled as Boolean?) + + /** Alias for calling [Builder.enabled] with `enabled.orElse(null)`. */ + fun enabled(enabled: Optional) = enabled(enabled.getOrNull()) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when the + * next attempt will occur. If dunning has been exhausted, or auto-collection is not + * enabled for this invoice, this field will be `null`. + */ + fun nextAttemptAt(nextAttemptAt: OffsetDateTime?) = + nextAttemptAt(JsonField.ofNullable(nextAttemptAt)) + + /** Alias for calling [Builder.nextAttemptAt] with `nextAttemptAt.orElse(null)`. */ + fun nextAttemptAt(nextAttemptAt: Optional) = + nextAttemptAt(nextAttemptAt.getOrNull()) + + /** + * Sets [Builder.nextAttemptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.nextAttemptAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nextAttemptAt(nextAttemptAt: JsonField) = apply { + this.nextAttemptAt = nextAttemptAt + } + + /** Number of auto-collection payment attempts. */ + fun numAttempts(numAttempts: Long?) = numAttempts(JsonField.ofNullable(numAttempts)) + + /** + * Alias for [Builder.numAttempts]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numAttempts(numAttempts: Long) = numAttempts(numAttempts as Long?) + + /** Alias for calling [Builder.numAttempts] with `numAttempts.orElse(null)`. */ + fun numAttempts(numAttempts: Optional) = numAttempts(numAttempts.getOrNull()) + + /** + * Sets [Builder.numAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.numAttempts] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numAttempts(numAttempts: JsonField) = apply { this.numAttempts = numAttempts } + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field will + * reflect when that attempt occurred. In conjunction with `next_attempt_at`, this can + * be used to tell whether the invoice is currently in dunning (that is, + * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or if + * dunning has been exhausted (`previously_attempted_at` is non-null, but + * `next_attempt_time` is null). + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: OffsetDateTime?) = + previouslyAttemptedAt(JsonField.ofNullable(previouslyAttemptedAt)) + + /** + * Alias for calling [Builder.previouslyAttemptedAt] with + * `previouslyAttemptedAt.orElse(null)`. + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: Optional) = + previouslyAttemptedAt(previouslyAttemptedAt.getOrNull()) + + /** + * Sets [Builder.previouslyAttemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.previouslyAttemptedAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: JsonField) = apply { + this.previouslyAttemptedAt = previouslyAttemptedAt + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoCollection]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoCollection = + AutoCollection( + checkRequired("enabled", enabled), + checkRequired("nextAttemptAt", nextAttemptAt), + checkRequired("numAttempts", numAttempts), + checkRequired("previouslyAttemptedAt", previouslyAttemptedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AutoCollection = apply { + if (validated) { + return@apply + } + + enabled() + nextAttemptAt() + numAttempts() + previouslyAttemptedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (enabled.asKnown().isPresent) 1 else 0) + + (if (nextAttemptAt.asKnown().isPresent) 1 else 0) + + (if (numAttempts.asKnown().isPresent) 1 else 0) + + (if (previouslyAttemptedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoCollection && + enabled == other.enabled && + nextAttemptAt == other.nextAttemptAt && + numAttempts == other.numAttempts && + previouslyAttemptedAt == other.previouslyAttemptedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + enabled, + nextAttemptAt, + numAttempts, + previouslyAttemptedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoCollection{enabled=$enabled, nextAttemptAt=$nextAttemptAt, numAttempts=$numAttempts, previouslyAttemptedAt=$previouslyAttemptedAt, additionalProperties=$additionalProperties}" + } + + class CreditNote + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val creditNoteNumber: JsonField, + private val memo: JsonField, + private val reason: JsonField, + private val total: JsonField, + private val type: JsonField, + private val voidedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("credit_note_number") + @ExcludeMissing + creditNoteNumber: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + voidedAt: JsonField = JsonMissing.of(), + ) : this(id, creditNoteNumber, memo, reason, total, type, voidedAt, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditNoteNumber(): String = creditNoteNumber.getRequired("credit_note_number") + + /** + * An optional memo supplied on the credit note. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memo(): Optional = memo.getOptional("memo") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun total(): String = total.getRequired("total") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): String = type.getRequired("type") + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit note + * was voided. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun voidedAt(): Optional = voidedAt.getOptional("voided_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [creditNoteNumber]. + * + * Unlike [creditNoteNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_note_number") + @ExcludeMissing + fun _creditNoteNumber(): JsonField = creditNoteNumber + + /** + * Returns the raw JSON value of [memo]. + * + * Unlike [memo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [total]. + * + * Unlike [total], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [voidedAt]. + * + * Unlike [voidedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("voided_at") + @ExcludeMissing + fun _voidedAt(): JsonField = voidedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreditNote]. + * + * The following fields are required: + * ```java + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditNote]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creditNoteNumber: JsonField? = null + private var memo: JsonField? = null + private var reason: JsonField? = null + private var total: JsonField? = null + private var type: JsonField? = null + private var voidedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditNote: CreditNote) = apply { + id = creditNote.id + creditNoteNumber = creditNote.creditNoteNumber + memo = creditNote.memo + reason = creditNote.reason + total = creditNote.total + type = creditNote.type + voidedAt = creditNote.voidedAt + additionalProperties = creditNote.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun creditNoteNumber(creditNoteNumber: String) = + creditNoteNumber(JsonField.of(creditNoteNumber)) + + /** + * Sets [Builder.creditNoteNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNoteNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditNoteNumber(creditNoteNumber: JsonField) = apply { + this.creditNoteNumber = creditNoteNumber + } + + /** An optional memo supplied on the credit note. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** Alias for calling [Builder.memo] with `memo.orElse(null)`. */ + fun memo(memo: Optional) = memo(memo.getOrNull()) + + /** + * Sets [Builder.memo] to an arbitrary JSON value. + * + * You should usually call [Builder.memo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun total(total: String) = total(JsonField.of(total)) + + /** + * Sets [Builder.total] to an arbitrary JSON value. + * + * You should usually call [Builder.total] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun total(total: JsonField) = apply { this.total = total } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit + * note was voided. + */ + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** Alias for calling [Builder.voidedAt] with `voidedAt.orElse(null)`. */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.getOrNull()) + + /** + * Sets [Builder.voidedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.voidedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreditNote]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditNote = + CreditNote( + checkRequired("id", id), + checkRequired("creditNoteNumber", creditNoteNumber), + checkRequired("memo", memo), + checkRequired("reason", reason), + checkRequired("total", total), + checkRequired("type", type), + checkRequired("voidedAt", voidedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CreditNote = apply { + if (validated) { + return@apply + } + + id() + creditNoteNumber() + memo() + reason() + total() + type() + voidedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creditNoteNumber.asKnown().isPresent) 1 else 0) + + (if (memo.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (total.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (voidedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditNote && + id == other.id && + creditNoteNumber == other.creditNoteNumber && + memo == other.memo && + reason == other.reason && + total == other.total && + type == other.type && + voidedAt == other.voidedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creditNoteNumber, + memo, + reason, + total, + type, + voidedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditNote{id=$id, creditNoteNumber=$creditNoteNumber, memo=$memo, reason=$reason, total=$total, type=$type, voidedAt=$voidedAt, additionalProperties=$additionalProperties}" + } + + class CustomerBalanceTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val action: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val creditNote: JsonField, + private val description: JsonField, + private val endingBalance: JsonField, + private val invoice: JsonField, + private val startingBalance: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("action") @ExcludeMissing action: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_note") + @ExcludeMissing + creditNote: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ending_balance") + @ExcludeMissing + endingBalance: JsonField = JsonMissing.of(), + @JsonProperty("invoice") + @ExcludeMissing + invoice: JsonField = JsonMissing.of(), + @JsonProperty("starting_balance") + @ExcludeMissing + startingBalance: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + mutableMapOf(), + ) + + /** + * A unique id for this transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * The value of the amount changed in the transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The creation time of this transaction. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditNote(): Optional = creditNote.getOptional("credit_note") + + /** + * An optional description provided for manual customer balance adjustments. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The new value of the customer's balance prior to the transaction, in the customer's + * currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endingBalance(): String = endingBalance.getRequired("ending_balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoice(): Optional = invoice.getOptional("invoice") + + /** + * The original value of the customer's balance prior to the transaction, in the customer's + * currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingBalance(): String = startingBalance.getRequired("starting_balance") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditNote]. + * + * Unlike [creditNote], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_note") + @ExcludeMissing + fun _creditNote(): JsonField = creditNote + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [endingBalance]. + * + * Unlike [endingBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance + + /** + * Returns the raw JSON value of [invoice]. + * + * Unlike [invoice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice + + /** + * Returns the raw JSON value of [startingBalance]. + * + * Unlike [startingBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransaction]. + * + * The following fields are required: + * ```java + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerBalanceTransaction]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var action: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditNote: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var invoice: JsonField? = null + private var startingBalance: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerBalanceTransaction: CustomerBalanceTransaction) = apply { + id = customerBalanceTransaction.id + action = customerBalanceTransaction.action + amount = customerBalanceTransaction.amount + createdAt = customerBalanceTransaction.createdAt + creditNote = customerBalanceTransaction.creditNote + description = customerBalanceTransaction.description + endingBalance = customerBalanceTransaction.endingBalance + invoice = customerBalanceTransaction.invoice + startingBalance = customerBalanceTransaction.startingBalance + type = customerBalanceTransaction.type + additionalProperties = + customerBalanceTransaction.additionalProperties.toMutableMap() + } + + /** A unique id for this transaction. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** The value of the amount changed in the transaction. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The creation time of this transaction. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditNote(creditNote: CreditNoteTiny?) = + creditNote(JsonField.ofNullable(creditNote)) + + /** Alias for calling [Builder.creditNote] with `creditNote.orElse(null)`. */ + fun creditNote(creditNote: Optional) = + creditNote(creditNote.getOrNull()) + + /** + * Sets [Builder.creditNote] to an arbitrary JSON value. + * + * You should usually call [Builder.creditNote] with a well-typed [CreditNoteTiny] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditNote(creditNote: JsonField) = apply { + this.creditNote = creditNote + } + + /** An optional description provided for manual customer balance adjustments. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * The new value of the customer's balance prior to the transaction, in the customer's + * currency. + */ + fun endingBalance(endingBalance: String) = endingBalance(JsonField.of(endingBalance)) + + /** + * Sets [Builder.endingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBalance] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endingBalance(endingBalance: JsonField) = apply { + this.endingBalance = endingBalance + } + + fun invoice(invoice: InvoiceTiny?) = invoice(JsonField.ofNullable(invoice)) + + /** Alias for calling [Builder.invoice] with `invoice.orElse(null)`. */ + fun invoice(invoice: Optional) = invoice(invoice.getOrNull()) + + /** + * Sets [Builder.invoice] to an arbitrary JSON value. + * + * You should usually call [Builder.invoice] with a well-typed [InvoiceTiny] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoice(invoice: JsonField) = apply { this.invoice = invoice } + + /** + * The original value of the customer's balance prior to the transaction, in the + * customer's currency. + */ + fun startingBalance(startingBalance: String) = + startingBalance(JsonField.of(startingBalance)) + + /** + * Sets [Builder.startingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.startingBalance] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomerBalanceTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerBalanceTransaction = + CustomerBalanceTransaction( + checkRequired("id", id), + checkRequired("action", action), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("creditNote", creditNote), + checkRequired("description", description), + checkRequired("endingBalance", endingBalance), + checkRequired("invoice", invoice), + checkRequired("startingBalance", startingBalance), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CustomerBalanceTransaction = apply { + if (validated) { + return@apply + } + + id() + action().validate() + amount() + createdAt() + creditNote().ifPresent { it.validate() } + description() + endingBalance() + invoice().ifPresent { it.validate() } + startingBalance() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditNote.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (invoice.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Action @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPLIED_TO_INVOICE = of("applied_to_invoice") + + @JvmField val MANUAL_ADJUSTMENT = of("manual_adjustment") + + @JvmField val PRORATED_REFUND = of("prorated_refund") + + @JvmField val REVERT_PRORATED_REFUND = of("revert_prorated_refund") + + @JvmField val RETURN_FROM_VOIDING = of("return_from_voiding") + + @JvmField val CREDIT_NOTE_APPLIED = of("credit_note_applied") + + @JvmField val CREDIT_NOTE_VOIDED = of("credit_note_voided") + + @JvmField val OVERPAYMENT_REFUND = of("overpayment_refund") + + @JvmField val EXTERNAL_PAYMENT = of("external_payment") + + @JvmField val SMALL_INVOICE_CARRYOVER = of("small_invoice_carryover") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + APPLIED_TO_INVOICE, + MANUAL_ADJUSTMENT, + PRORATED_REFUND, + REVERT_PRORATED_REFUND, + RETURN_FROM_VOIDING, + CREDIT_NOTE_APPLIED, + CREDIT_NOTE_VOIDED, + OVERPAYMENT_REFUND, + EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPLIED_TO_INVOICE, + MANUAL_ADJUSTMENT, + PRORATED_REFUND, + REVERT_PRORATED_REFUND, + RETURN_FROM_VOIDING, + CREDIT_NOTE_APPLIED, + CREDIT_NOTE_VOIDED, + OVERPAYMENT_REFUND, + EXTERNAL_PAYMENT, + SMALL_INVOICE_CARRYOVER, + /** + * An enum member indicating that [Action] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPLIED_TO_INVOICE -> Value.APPLIED_TO_INVOICE + MANUAL_ADJUSTMENT -> Value.MANUAL_ADJUSTMENT + PRORATED_REFUND -> Value.PRORATED_REFUND + REVERT_PRORATED_REFUND -> Value.REVERT_PRORATED_REFUND + RETURN_FROM_VOIDING -> Value.RETURN_FROM_VOIDING + CREDIT_NOTE_APPLIED -> Value.CREDIT_NOTE_APPLIED + CREDIT_NOTE_VOIDED -> Value.CREDIT_NOTE_VOIDED + OVERPAYMENT_REFUND -> Value.OVERPAYMENT_REFUND + EXTERNAL_PAYMENT -> Value.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Value.SMALL_INVOICE_CARRYOVER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPLIED_TO_INVOICE -> Known.APPLIED_TO_INVOICE + MANUAL_ADJUSTMENT -> Known.MANUAL_ADJUSTMENT + PRORATED_REFUND -> Known.PRORATED_REFUND + REVERT_PRORATED_REFUND -> Known.REVERT_PRORATED_REFUND + RETURN_FROM_VOIDING -> Known.RETURN_FROM_VOIDING + CREDIT_NOTE_APPLIED -> Known.CREDIT_NOTE_APPLIED + CREDIT_NOTE_VOIDED -> Known.CREDIT_NOTE_VOIDED + OVERPAYMENT_REFUND -> Known.OVERPAYMENT_REFUND + EXTERNAL_PAYMENT -> Known.EXTERNAL_PAYMENT + SMALL_INVOICE_CARRYOVER -> Known.SMALL_INVOICE_CARRYOVER + else -> throw OrbInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INCREMENT = of("increment") + + @JvmField val DECREMENT = of("decrement") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + INCREMENT, + DECREMENT, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCREMENT, + DECREMENT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCREMENT -> Value.INCREMENT + DECREMENT -> Value.DECREMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCREMENT -> Known.INCREMENT + DECREMENT -> Known.DECREMENT + else -> throw OrbInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomerBalanceTransaction && + id == other.id && + action == other.action && + amount == other.amount && + createdAt == other.createdAt && + creditNote == other.creditNote && + description == other.description && + endingBalance == other.endingBalance && + invoice == other.invoice && + startingBalance == other.startingBalance && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + action, + amount, + createdAt, + creditNote, + description, + endingBalance, + invoice, + startingBalance, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerBalanceTransaction{id=$id, action=$action, amount=$amount, createdAt=$createdAt, creditNote=$creditNote, description=$description, endingBalance=$endingBalance, invoice=$invoice, startingBalance=$startingBalance, type=$type, additionalProperties=$additionalProperties}" + } + + class InvoiceSource @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUBSCRIPTION = of("subscription") + + @JvmField val PARTIAL = of("partial") + + @JvmField val ONE_OFF = of("one_off") + + @JvmStatic fun of(value: String) = InvoiceSource(JsonField.of(value)) + } + + /** An enum containing [InvoiceSource]'s known values. */ + enum class Known { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, + } + + /** + * An enum containing [InvoiceSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InvoiceSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, + /** + * An enum member indicating that [InvoiceSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUBSCRIPTION -> Value.SUBSCRIPTION + PARTIAL -> Value.PARTIAL + ONE_OFF -> Value.ONE_OFF + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + SUBSCRIPTION -> Known.SUBSCRIPTION + PARTIAL -> Known.PARTIAL + ONE_OFF -> Known.ONE_OFF + else -> throw OrbInvalidDataException("Unknown InvoiceSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): InvoiceSource = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceSource && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PaymentAttempt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val amount: JsonField, + private val createdAt: JsonField, + private val paymentProvider: JsonField, + private val paymentProviderId: JsonField, + private val receiptPdf: JsonField, + private val succeeded: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("receipt_pdf") + @ExcludeMissing + receiptPdf: JsonField = JsonMissing.of(), + @JsonProperty("succeeded") + @ExcludeMissing + succeeded: JsonField = JsonMissing.of(), + ) : this( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + receiptPdf, + succeeded, + mutableMapOf(), + ) + + /** + * The ID of the payment attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The amount of the payment attempt. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amount(): String = amount.getRequired("amount") + + /** + * The time at which the payment attempt was created. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The payment provider that attempted to collect the payment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProvider(): Optional = + paymentProvider.getOptional("payment_provider") + + /** + * The ID of the payment attempt in the payment provider. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentProviderId(): Optional = + paymentProviderId.getOptional("payment_provider_id") + + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for payment + * attempts that did not succeed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun receiptPdf(): Optional = receiptPdf.getOptional("receipt_pdf") + + /** + * Whether the payment attempt succeeded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun succeeded(): Boolean = succeeded.getRequired("succeeded") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [paymentProvider]. + * + * Unlike [paymentProvider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider + + /** + * Returns the raw JSON value of [paymentProviderId]. + * + * Unlike [paymentProviderId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_provider_id") + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId + + /** + * Returns the raw JSON value of [receiptPdf]. + * + * Unlike [receiptPdf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("receipt_pdf") + @ExcludeMissing + fun _receiptPdf(): JsonField = receiptPdf + + /** + * Returns the raw JSON value of [succeeded]. + * + * Unlike [succeeded], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("succeeded") @ExcludeMissing fun _succeeded(): JsonField = succeeded + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PaymentAttempt]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .receiptPdf() + * .succeeded() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaymentAttempt]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var paymentProvider: JsonField? = null + private var paymentProviderId: JsonField? = null + private var receiptPdf: JsonField? = null + private var succeeded: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paymentAttempt: PaymentAttempt) = apply { + id = paymentAttempt.id + amount = paymentAttempt.amount + createdAt = paymentAttempt.createdAt + paymentProvider = paymentAttempt.paymentProvider + paymentProviderId = paymentAttempt.paymentProviderId + receiptPdf = paymentAttempt.receiptPdf + succeeded = paymentAttempt.succeeded + additionalProperties = paymentAttempt.additionalProperties.toMutableMap() + } + + /** The ID of the payment attempt. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of the payment attempt. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The time at which the payment attempt was created. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** The payment provider that attempted to collect the payment. */ + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) + + /** Alias for calling [Builder.paymentProvider] with `paymentProvider.orElse(null)`. */ + fun paymentProvider(paymentProvider: Optional) = + paymentProvider(paymentProvider.getOrNull()) + + /** + * Sets [Builder.paymentProvider] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProvider] with a well-typed [PaymentProvider] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + this.paymentProvider = paymentProvider + } + + /** The ID of the payment attempt in the payment provider. */ + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * Alias for calling [Builder.paymentProviderId] with `paymentProviderId.orElse(null)`. + */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.getOrNull()) + + /** + * Sets [Builder.paymentProviderId] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentProviderId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + /** + * URL to the downloadable PDF version of the receipt. This field will be `null` for + * payment attempts that did not succeed. + */ + fun receiptPdf(receiptPdf: String?) = receiptPdf(JsonField.ofNullable(receiptPdf)) + + /** Alias for calling [Builder.receiptPdf] with `receiptPdf.orElse(null)`. */ + fun receiptPdf(receiptPdf: Optional) = receiptPdf(receiptPdf.getOrNull()) + + /** + * Sets [Builder.receiptPdf] to an arbitrary JSON value. + * + * You should usually call [Builder.receiptPdf] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun receiptPdf(receiptPdf: JsonField) = apply { this.receiptPdf = receiptPdf } + + /** Whether the payment attempt succeeded. */ + fun succeeded(succeeded: Boolean) = succeeded(JsonField.of(succeeded)) + + /** + * Sets [Builder.succeeded] to an arbitrary JSON value. + * + * You should usually call [Builder.succeeded] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun succeeded(succeeded: JsonField) = apply { this.succeeded = succeeded } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PaymentAttempt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .receiptPdf() + * .succeeded() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentAttempt = + PaymentAttempt( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("paymentProvider", paymentProvider), + checkRequired("paymentProviderId", paymentProviderId), + checkRequired("receiptPdf", receiptPdf), + checkRequired("succeeded", succeeded), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PaymentAttempt = apply { + if (validated) { + return@apply + } + + id() + amount() + createdAt() + paymentProvider().ifPresent { it.validate() } + paymentProviderId() + receiptPdf() + succeeded() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (paymentProvider.asKnown().getOrNull()?.validity() ?: 0) + + (if (paymentProviderId.asKnown().isPresent) 1 else 0) + + (if (receiptPdf.asKnown().isPresent) 1 else 0) + + (if (succeeded.asKnown().isPresent) 1 else 0) + + /** The payment provider that attempted to collect the payment. */ + class PaymentProvider + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val STRIPE = of("stripe") + + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) + } + + /** An enum containing [PaymentProvider]'s known values. */ + enum class Known { + STRIPE + } + + /** + * An enum containing [PaymentProvider]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PaymentProvider] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STRIPE, + /** + * An enum member indicating that [PaymentProvider] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STRIPE -> Value.STRIPE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STRIPE -> Known.STRIPE + else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PaymentProvider = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentProvider && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentAttempt && + id == other.id && + amount == other.amount && + createdAt == other.createdAt && + paymentProvider == other.paymentProvider && + paymentProviderId == other.paymentProviderId && + receiptPdf == other.receiptPdf && + succeeded == other.succeeded && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + createdAt, + paymentProvider, + paymentProviderId, + receiptPdf, + succeeded, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, receiptPdf=$receiptPdf, succeeded=$succeeded, additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ISSUED = of("issued") + + @JvmField val PAID = of("paid") + + @JvmField val SYNCED = of("synced") + + @JvmField val VOID = of("void") + + @JvmField val DRAFT = of("draft") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ISSUED, + PAID, + SYNCED, + VOID, + DRAFT, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ISSUED -> Value.ISSUED + PAID -> Value.PAID + SYNCED -> Value.SYNCED + VOID -> Value.VOID + DRAFT -> Value.DRAFT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ISSUED -> Known.ISSUED + PAID -> Known.PAID + SYNCED -> Known.SYNCED + VOID -> Known.VOID + DRAFT -> Known.DRAFT + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceIssueSummaryResponse && + id == other.id && + amountDue == other.amountDue && + autoCollection == other.autoCollection && + billingAddress == other.billingAddress && + createdAt == other.createdAt && + creditNotes == other.creditNotes && + currency == other.currency && + customer == other.customer && + customerBalanceTransactions == other.customerBalanceTransactions && + customerTaxId == other.customerTaxId && + dueDate == other.dueDate && + eligibleToIssueAt == other.eligibleToIssueAt && + hostedInvoiceUrl == other.hostedInvoiceUrl && + invoiceDate == other.invoiceDate && + invoiceNumber == other.invoiceNumber && + invoicePdf == other.invoicePdf && + invoiceSource == other.invoiceSource && + issueFailedAt == other.issueFailedAt && + issuedAt == other.issuedAt && + memo == other.memo && + metadata == other.metadata && + paidAt == other.paidAt && + paymentAttempts == other.paymentAttempts && + paymentFailedAt == other.paymentFailedAt && + paymentStartedAt == other.paymentStartedAt && + scheduledIssueAt == other.scheduledIssueAt && + shippingAddress == other.shippingAddress && + status == other.status && + subscription == other.subscription && + syncFailedAt == other.syncFailedAt && + total == other.total && + voidedAt == other.voidedAt && + willAutoIssue == other.willAutoIssue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amountDue, + autoCollection, + billingAddress, + createdAt, + creditNotes, + currency, + customer, + customerBalanceTransactions, + customerTaxId, + dueDate, + eligibleToIssueAt, + hostedInvoiceUrl, + invoiceDate, + invoiceNumber, + invoicePdf, + invoiceSource, + issueFailedAt, + issuedAt, + memo, + metadata, + paidAt, + paymentAttempts, + paymentFailedAt, + paymentStartedAt, + scheduledIssueAt, + shippingAddress, + status, + subscription, + syncFailedAt, + total, + voidedAt, + willAutoIssue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoiceIssueSummaryResponse{id=$id, amountDue=$amountDue, autoCollection=$autoCollection, billingAddress=$billingAddress, createdAt=$createdAt, creditNotes=$creditNotes, currency=$currency, customer=$customer, customerBalanceTransactions=$customerBalanceTransactions, customerTaxId=$customerTaxId, dueDate=$dueDate, eligibleToIssueAt=$eligibleToIssueAt, hostedInvoiceUrl=$hostedInvoiceUrl, invoiceDate=$invoiceDate, invoiceNumber=$invoiceNumber, invoicePdf=$invoicePdf, invoiceSource=$invoiceSource, issueFailedAt=$issueFailedAt, issuedAt=$issuedAt, memo=$memo, metadata=$metadata, paidAt=$paidAt, paymentAttempts=$paymentAttempts, paymentFailedAt=$paymentFailedAt, paymentStartedAt=$paymentStartedAt, scheduledIssueAt=$scheduledIssueAt, shippingAddress=$shippingAddress, status=$status, subscription=$subscription, syncFailedAt=$syncFailedAt, total=$total, voidedAt=$voidedAt, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt index 965cdd22f..41b6b8be0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscount.kt @@ -48,6 +48,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = invoiceLevelDiscount.accept(new InvoiceLevelDiscount.Visitor>() { + * @Override + * public Optional visitPercentage(PercentageDiscount percentage) { + * return Optional.of(percentage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and the + * current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentage != null -> visitor.visitPercentage(percentage) @@ -58,6 +87,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): InvoiceLevelDiscount = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt index 88b6c336d..cf171f92a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt @@ -802,6 +802,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply 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 7522377b2..e99a54ae2 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 @@ -746,6 +746,13 @@ private constructor( fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) @@ -826,6 +833,14 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: Price.MinimumComposite) = price(Price.ofMinimumComposite(minimumComposite)) @@ -1040,6 +1055,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): InvoiceLineItemCreateResponse = apply { if (validated) { return@apply @@ -1148,6 +1171,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitUsageDiscount(MonetaryUsageDiscountAdjustment usageDiscount) { + * return Optional.of(usageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) @@ -1160,6 +1212,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -1414,6 +1475,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = subLineItem.accept(new SubLineItem.Visitor>() { + * @Override + * public Optional visitMatrix(MatrixSubLineItem matrix) { + * return Optional.of(matrix.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { matrix != null -> visitor.visitMatrix(matrix) @@ -1424,6 +1514,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): SubLineItem = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt index 2a11d0960..f405e5265 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageResponse.kt @@ -185,6 +185,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): InvoiceListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt index ea9bc94ae..924db417f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt @@ -30,6 +30,10 @@ import kotlin.jvm.optionals.getOrNull * When fetching any `draft` invoices, this returns the last-computed invoice values for each draft * invoice, which may not always be up-to-date since Orb regularly refreshes invoices * asynchronously. + * + * If you don't need line item details, minimums, maximums, or discounts, prefer the + * [list invoices summary](/api-reference/invoice/list-invoices-summary) endpoint for better + * performance. */ class InvoiceListParams private constructor( @@ -568,6 +572,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DateType = apply { if (validated) { return@apply @@ -710,6 +723,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryPageResponse.kt index 441f5ebb1..cbf213eae 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryPageResponse.kt @@ -191,6 +191,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): InvoiceListSummaryPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryParams.kt index 753d43e92..7cfb73618 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryParams.kt @@ -561,6 +561,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DateType = apply { if (validated) { return@apply @@ -703,6 +712,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryResponse.kt index 64ec70dca..a8613a81e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListSummaryResponse.kt @@ -306,11 +306,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -322,6 +324,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -352,9 +355,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -372,6 +377,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -1213,11 +1219,13 @@ private constructor( * |Estonia |`eu_vat` |European VAT Number | * |Ethiopia |`et_tin` |Ethiopia Tax Identification Number | * |European Union |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Faroe Islands |`fo_vat` |Faroe Islands VAT Number | * |Finland |`eu_vat` |European VAT Number | * |France |`eu_vat` |European VAT Number | * |Georgia |`ge_vat` |Georgian VAT | * |Germany |`de_stn` |German Tax Number (Steuernummer) | * |Germany |`eu_vat` |European VAT Number | + * |Gibraltar |`gi_tin` |Gibraltar Tax Identification Number | * |Greece |`eu_vat` |European VAT Number | * |Guinea |`gn_nif` |Guinea Tax Identification Number (Número de Identificação Fiscal) | * |Hong Kong |`hk_br` |Hong Kong BR Number | @@ -1229,6 +1237,7 @@ private constructor( * |Ireland |`eu_vat` |European VAT Number | * |Israel |`il_vat` |Israel VAT | * |Italy |`eu_vat` |European VAT Number | + * |Italy |`it_cf` |Italian Codice Fiscale Number | * |Japan |`jp_cn` |Japanese Corporate Number (*Hōjin Bangō*) | * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*)| * |Japan |`jp_trn` |Japanese Tax Registration Number (*Tōroku Bangō*) | @@ -1259,9 +1268,11 @@ private constructor( * |Norway |`no_vat` |Norwegian VAT Number | * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | * |Oman |`om_vat` |Omani VAT Number | + * |Paraguay |`py_ruc` |Paraguayan RUC Number | * |Peru |`pe_ruc` |Peruvian RUC Number | * |Philippines |`ph_tin` |Philippines Tax Identification Number | * |Poland |`eu_vat` |European VAT Number | + * |Poland |`pl_nip` |Polish Tax ID Number | * |Portugal |`eu_vat` |European VAT Number | * |Romania |`eu_vat` |European VAT Number | * |Romania |`ro_tin` |Romanian Tax ID Number | @@ -1279,6 +1290,7 @@ private constructor( * |South Korea |`kr_brn` |Korean BRN | * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | * |Spain |`eu_vat` |European VAT Number | + * |Sri Lanka |`lk_vat` |Sri Lanka VAT Number | * |Suriname |`sr_fin` |Suriname FIN Number | * |Sweden |`eu_vat` |European VAT Number | * |Switzerland |`ch_uid` |Switzerland UID Number | @@ -1842,6 +1854,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): InvoiceListSummaryResponse = apply { if (validated) { return@apply @@ -2221,6 +2241,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AutoCollection = apply { if (validated) { return@apply @@ -2610,6 +2639,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CreditNote = apply { if (validated) { return@apply @@ -3162,6 +3200,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CustomerBalanceTransaction = apply { if (validated) { return@apply @@ -3344,6 +3391,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Action = apply { if (validated) { return@apply @@ -3469,6 +3526,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply @@ -3644,6 +3711,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InvoiceSource = apply { if (validated) { return@apply @@ -3745,6 +3821,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -4162,6 +4247,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentAttempt = apply { if (validated) { return@apply @@ -4288,6 +4382,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PaymentProvider = apply { if (validated) { return@apply @@ -4465,6 +4569,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply 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 6ccfcd736..3d9a51a06 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 @@ -530,6 +530,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply 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 feb007580..caf48d88d 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 @@ -2,31 +2,56 @@ package com.withorb.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.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 com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections 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 - * action can only be taken on invoices with status "issued". + * This endpoint collects payment for an invoice. By default, it uses the customer's default payment + * method. Optionally, a shared payment token (SPT) can be provided to pay using agent-granted + * credentials instead. This action can only be taken on invoices with status "issued". */ class InvoicePayParams private constructor( private val invoiceId: String?, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, ) : Params { fun invoiceId(): Optional = Optional.ofNullable(invoiceId) - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties + /** + * The ID of a shared payment token granted by an agent to use for this payment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun sharedPaymentTokenId(): String = body.sharedPaymentTokenId() + + /** + * Returns the raw JSON value of [sharedPaymentTokenId]. + * + * Unlike [sharedPaymentTokenId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _sharedPaymentTokenId(): JsonField = body._sharedPaymentTokenId() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -38,9 +63,14 @@ private constructor( companion object { - @JvmStatic fun none(): InvoicePayParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [InvoicePayParams]. */ + /** + * Returns a mutable builder for constructing an instance of [InvoicePayParams]. + * + * The following fields are required: + * ```java + * .sharedPaymentTokenId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -48,16 +78,16 @@ private constructor( class Builder internal constructor() { private var invoiceId: String? = null + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(invoicePayParams: InvoicePayParams) = apply { invoiceId = invoicePayParams.invoiceId + body = invoicePayParams.body.toBuilder() additionalHeaders = invoicePayParams.additionalHeaders.toBuilder() additionalQueryParams = invoicePayParams.additionalQueryParams.toBuilder() - additionalBodyProperties = invoicePayParams.additionalBodyProperties.toMutableMap() } fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } @@ -65,6 +95,50 @@ private constructor( /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.getOrNull()) + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [sharedPaymentTokenId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The ID of a shared payment token granted by an agent to use for this payment. */ + fun sharedPaymentTokenId(sharedPaymentTokenId: String) = apply { + body.sharedPaymentTokenId(sharedPaymentTokenId) + } + + /** + * Sets [Builder.sharedPaymentTokenId] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPaymentTokenId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPaymentTokenId(sharedPaymentTokenId: JsonField) = apply { + body.sharedPaymentTokenId(sharedPaymentTokenId) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -163,44 +237,28 @@ private constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - /** * Returns an immutable instance of [InvoicePayParams]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sharedPaymentTokenId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): InvoicePayParams = InvoicePayParams( invoiceId, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { @@ -212,6 +270,186 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sharedPaymentTokenId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("shared_payment_token_id") + @ExcludeMissing + sharedPaymentTokenId: JsonField = JsonMissing.of() + ) : this(sharedPaymentTokenId, mutableMapOf()) + + /** + * The ID of a shared payment token granted by an agent to use for this payment. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sharedPaymentTokenId(): String = + sharedPaymentTokenId.getRequired("shared_payment_token_id") + + /** + * Returns the raw JSON value of [sharedPaymentTokenId]. + * + * Unlike [sharedPaymentTokenId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("shared_payment_token_id") + @ExcludeMissing + fun _sharedPaymentTokenId(): JsonField = sharedPaymentTokenId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .sharedPaymentTokenId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var sharedPaymentTokenId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + sharedPaymentTokenId = body.sharedPaymentTokenId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The ID of a shared payment token granted by an agent to use for this payment. */ + fun sharedPaymentTokenId(sharedPaymentTokenId: String) = + sharedPaymentTokenId(JsonField.of(sharedPaymentTokenId)) + + /** + * Sets [Builder.sharedPaymentTokenId] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPaymentTokenId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun sharedPaymentTokenId(sharedPaymentTokenId: JsonField) = apply { + this.sharedPaymentTokenId = sharedPaymentTokenId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sharedPaymentTokenId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("sharedPaymentTokenId", sharedPaymentTokenId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + sharedPaymentTokenId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (sharedPaymentTokenId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + sharedPaymentTokenId == other.sharedPaymentTokenId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sharedPaymentTokenId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{sharedPaymentTokenId=$sharedPaymentTokenId, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -219,14 +457,14 @@ private constructor( return other is InvoicePayParams && invoiceId == other.invoiceId && + body == other.body && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties + additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(invoiceId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + Objects.hash(invoiceId, body, additionalHeaders, additionalQueryParams) override fun toString() = - "InvoicePayParams{invoiceId=$invoiceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "InvoicePayParams{invoiceId=$invoiceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt index fb6ef310d..f86264a2f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceTiny.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): InvoiceTiny = apply { if (validated) { return@apply 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 eb12e7a91..49900bd92 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 @@ -34,13 +34,13 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and `invoice_date` - * properties on an invoice. If you pass null for the metadata value, it will clear any existing - * metadata for that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, and + * `auto_collection` properties on an invoice. If you pass null for the metadata value, it will + * clear any existing metadata for that invoice. * - * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, and - * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can only - * be modified for non-subscription invoices. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, `invoice_date`, + * and `auto_collection` can only be modified if the invoice is in a `draft` state. `invoice_date` + * can only be modified for non-subscription invoices. */ class InvoiceUpdateParams private constructor( @@ -52,6 +52,16 @@ private constructor( fun invoiceId(): Optional = Optional.ofNullable(invoiceId) + /** + * Determines whether this invoice will automatically attempt to charge a saved payment method, + * if any. Can only be modified on draft invoices. If not specified, the invoice's existing + * setting is unchanged. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun autoCollection(): Optional = body.autoCollection() + /** * An optional custom due date for the invoice. If not set, the due date will be calculated * based on the `net_terms` value. @@ -91,6 +101,13 @@ private constructor( */ fun netTerms(): Optional = body.netTerms() + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _autoCollection(): JsonField = body._autoCollection() + /** * Returns the raw JSON value of [dueDate]. * @@ -163,13 +180,44 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [autoCollection] * - [dueDate] * - [invoiceDate] * - [metadata] * - [netTerms] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. Can only be modified on draft invoices. If not specified, the invoice's + * existing setting is unchanged. + */ + fun autoCollection(autoCollection: Boolean?) = apply { body.autoCollection(autoCollection) } + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + /** * An optional custom due date for the invoice. If not set, the due date will be calculated * based on the `net_terms` value. @@ -408,6 +456,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val autoCollection: JsonField, private val dueDate: JsonField, private val invoiceDate: JsonField, private val metadata: JsonField, @@ -417,6 +466,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("auto_collection") + @ExcludeMissing + autoCollection: JsonField = JsonMissing.of(), @JsonProperty("due_date") @ExcludeMissing dueDate: JsonField = JsonMissing.of(), @@ -427,7 +479,17 @@ private constructor( @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing netTerms: JsonField = JsonMissing.of(), - ) : this(dueDate, invoiceDate, metadata, netTerms, mutableMapOf()) + ) : this(autoCollection, dueDate, invoiceDate, metadata, netTerms, mutableMapOf()) + + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. Can only be modified on draft invoices. If not specified, the invoice's + * existing setting is unchanged. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun autoCollection(): Optional = autoCollection.getOptional("auto_collection") /** * An optional custom due date for the invoice. If not set, the due date will be calculated @@ -468,6 +530,16 @@ private constructor( */ fun netTerms(): Optional = netTerms.getOptional("net_terms") + /** + * Returns the raw JSON value of [autoCollection]. + * + * Unlike [autoCollection], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + /** * Returns the raw JSON value of [dueDate]. * @@ -519,6 +591,7 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var autoCollection: JsonField = JsonMissing.of() private var dueDate: JsonField = JsonMissing.of() private var invoiceDate: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() @@ -527,6 +600,7 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { + autoCollection = body.autoCollection dueDate = body.dueDate invoiceDate = body.invoiceDate metadata = body.metadata @@ -534,6 +608,36 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** + * Determines whether this invoice will automatically attempt to charge a saved payment + * method, if any. Can only be modified on draft invoices. If not specified, the + * invoice's existing setting is unchanged. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Alias for [Builder.autoCollection]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** Alias for calling [Builder.autoCollection] with `autoCollection.orElse(null)`. */ + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.getOrNull()) + + /** + * Sets [Builder.autoCollection] to an arbitrary JSON value. + * + * You should usually call [Builder.autoCollection] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + /** * An optional custom due date for the invoice. If not set, the due date will be * calculated based on the `net_terms` value. @@ -656,16 +760,33 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Body = - Body(dueDate, invoiceDate, metadata, netTerms, additionalProperties.toMutableMap()) + Body( + autoCollection, + dueDate, + invoiceDate, + metadata, + netTerms, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply } + autoCollection() dueDate().ifPresent { it.validate() } invoiceDate().ifPresent { it.validate() } metadata().ifPresent { it.validate() } @@ -689,7 +810,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (dueDate.asKnown().getOrNull()?.validity() ?: 0) + + (if (autoCollection.asKnown().isPresent) 1 else 0) + + (dueDate.asKnown().getOrNull()?.validity() ?: 0) + (invoiceDate.asKnown().getOrNull()?.validity() ?: 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) @@ -700,6 +822,7 @@ private constructor( } return other is Body && + autoCollection == other.autoCollection && dueDate == other.dueDate && invoiceDate == other.invoiceDate && metadata == other.metadata && @@ -708,13 +831,20 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(dueDate, invoiceDate, metadata, netTerms, additionalProperties) + Objects.hash( + autoCollection, + dueDate, + invoiceDate, + metadata, + netTerms, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{dueDate=$dueDate, invoiceDate=$invoiceDate, metadata=$metadata, netTerms=$netTerms, additionalProperties=$additionalProperties}" + "Body{autoCollection=$autoCollection, dueDate=$dueDate, invoiceDate=$invoiceDate, metadata=$metadata, netTerms=$netTerms, additionalProperties=$additionalProperties}" } /** @@ -744,6 +874,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dueDate.accept(new DueDate.Visitor>() { + * @Override + * public Optional visitDate(LocalDate date) { + * return Optional.of(date.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { date != null -> visitor.visitDate(date) @@ -753,6 +912,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DueDate = apply { if (validated) { return@apply @@ -914,6 +1082,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = invoiceDate.accept(new InvoiceDate.Visitor>() { + * @Override + * public Optional visitDate(LocalDate date) { + * return Optional.of(date.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { date != null -> visitor.visitDate(date) @@ -923,6 +1120,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InvoiceDate = apply { if (validated) { return@apply @@ -1124,6 +1330,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt index 47f387c3c..c35706509 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -352,6 +352,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Item = apply { if (validated) { return@apply @@ -560,6 +568,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExternalConnection = apply { if (validated) { return@apply @@ -622,6 +639,8 @@ private constructor( @JvmField val NUMERAL = of("numeral") + @JvmField val STRIPE_TAX = of("stripe_tax") + @JvmStatic fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -635,6 +654,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, } /** @@ -657,6 +677,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -681,6 +702,7 @@ private constructor( AVALARA -> Value.AVALARA ANROK -> Value.ANROK NUMERAL -> Value.NUMERAL + STRIPE_TAX -> Value.STRIPE_TAX else -> Value._UNKNOWN } @@ -703,6 +725,7 @@ private constructor( AVALARA -> Known.AVALARA ANROK -> Known.ANROK NUMERAL -> Known.NUMERAL + STRIPE_TAX -> Known.STRIPE_TAX else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } @@ -720,6 +743,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExternalConnectionName = apply { if (validated) { return@apply @@ -842,6 +875,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt index fd2997395..6b032896d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt @@ -432,6 +432,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -543,6 +552,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt index 458052ff6..fe3cbaafe 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageResponse.kt @@ -184,6 +184,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): ItemListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt index d25ebf083..8e89f20ec 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlim.kt @@ -164,6 +164,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): ItemSlim = apply { if (validated) { return@apply 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 a7e8634c9..5372d3d4f 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 @@ -541,6 +541,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -766,6 +775,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExternalConnection = apply { if (validated) { return@apply @@ -828,6 +846,8 @@ private constructor( @JvmField val NUMERAL = of("numeral") + @JvmField val STRIPE_TAX = of("stripe_tax") + @JvmStatic fun of(value: String) = ExternalConnectionName(JsonField.of(value)) } @@ -841,6 +861,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, } /** @@ -863,6 +884,7 @@ private constructor( AVALARA, ANROK, NUMERAL, + STRIPE_TAX, /** * An enum member indicating that [ExternalConnectionName] was instantiated with an * unknown value. @@ -887,6 +909,7 @@ private constructor( AVALARA -> Value.AVALARA ANROK -> Value.ANROK NUMERAL -> Value.NUMERAL + STRIPE_TAX -> Value.STRIPE_TAX else -> Value._UNKNOWN } @@ -909,6 +932,7 @@ private constructor( AVALARA -> Known.AVALARA ANROK -> Known.ANROK NUMERAL -> Known.NUMERAL + STRIPE_TAX -> Known.STRIPE_TAX else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") } @@ -926,6 +950,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ExternalConnectionName = apply { if (validated) { return@apply @@ -1048,6 +1082,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt new file mode 100644 index 000000000..8dc1f437d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateParams.kt @@ -0,0 +1,770 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.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.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint is used to create a new license for a user. + * + * If a start date is provided, the license will be activated at the **start** of the specified date + * in the customer's timezone. Otherwise, the activation time will default to the **start** of the + * current day in the customer's timezone. + */ +class LicenseCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The external identifier for the license. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = body.externalLicenseId() + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = body.licenseTypeId() + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = body.subscriptionId() + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = body.endDate() + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun startDate(): Optional = body.startDate() + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _externalLicenseId(): JsonField = body._externalLicenseId() + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _licenseTypeId(): JsonField = body._licenseTypeId() + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _subscriptionId(): JsonField = body._subscriptionId() + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endDate(): JsonField = body._endDate() + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startDate(): JsonField = body._startDate() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseCreateParams]. + * + * The following fields are required: + * ```java + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseCreateParams: LicenseCreateParams) = apply { + body = licenseCreateParams.body.toBuilder() + additionalHeaders = licenseCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [externalLicenseId] + * - [licenseTypeId] + * - [subscriptionId] + * - [endDate] + * - [startDate] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The external identifier for the license. */ + fun externalLicenseId(externalLicenseId: String) = apply { + body.externalLicenseId(externalLicenseId) + } + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + body.externalLicenseId(externalLicenseId) + } + + fun licenseTypeId(licenseTypeId: String) = apply { body.licenseTypeId(licenseTypeId) } + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + body.licenseTypeId(licenseTypeId) + } + + fun subscriptionId(subscriptionId: String) = apply { body.subscriptionId(subscriptionId) } + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + body.subscriptionId(subscriptionId) + } + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + */ + fun endDate(endDate: LocalDate?) = apply { body.endDate(endDate) } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + */ + fun startDate(startDate: LocalDate?) = apply { body.startDate(startDate) } + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseCreateParams = + LicenseCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val subscriptionId: JsonField, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this( + externalLicenseId, + licenseTypeId, + subscriptionId, + endDate, + startDate, + mutableMapOf(), + ) + + /** + * The external identifier for the license. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startDate(): Optional = startDate.getOptional("start_date") + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var subscriptionId: JsonField? = null + private var endDate: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + externalLicenseId = body.externalLicenseId + licenseTypeId = body.licenseTypeId + subscriptionId = body.subscriptionId + endDate = body.endDate + startDate = body.startDate + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The external identifier for the license. */ + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * The end date of the license. If not provided, the license will remain active until + * deactivated. + */ + fun endDate(endDate: LocalDate?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The start date of the license. If not provided, defaults to start of day today in the + * customer's timezone. + */ + fun startDate(startDate: LocalDate?) = startDate(JsonField.ofNullable(startDate)) + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .externalLicenseId() + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + endDate, + startDate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + externalLicenseId() + licenseTypeId() + subscriptionId() + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + endDate == other.endDate && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + externalLicenseId, + licenseTypeId, + subscriptionId, + endDate, + startDate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt new file mode 100644 index 000000000..9f5d5f390 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseCreateResponse.kt @@ -0,0 +1,569 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseCreateResponse: LicenseCreateResponse) = apply { + id = licenseCreateResponse.id + endDate = licenseCreateResponse.endDate + externalLicenseId = licenseCreateResponse.externalLicenseId + licenseTypeId = licenseCreateResponse.licenseTypeId + startDate = licenseCreateResponse.startDate + status = licenseCreateResponse.status + subscriptionId = licenseCreateResponse.subscriptionId + additionalProperties = licenseCreateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseCreateResponse = + LicenseCreateResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseCreateResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseCreateResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseCreateResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt new file mode 100644 index 000000000..cc2f7b785 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateParams.kt @@ -0,0 +1,441 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint is used to deactivate an existing license. + * + * If an end date is provided, the license will be deactivated at the **start** of the specified + * date in the customer's timezone. Otherwise, the deactivation time will default to the **end** of + * the current day in the customer's timezone. + */ +class LicenseDeactivateParams +private constructor( + private val licenseId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseId(): Optional = Optional.ofNullable(licenseId) + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = body.endDate() + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endDate(): JsonField = body._endDate() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseDeactivateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LicenseDeactivateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseDeactivateParams]. */ + class Builder internal constructor() { + + private var licenseId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseDeactivateParams: LicenseDeactivateParams) = apply { + licenseId = licenseDeactivateParams.licenseId + body = licenseDeactivateParams.body.toBuilder() + additionalHeaders = licenseDeactivateParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseDeactivateParams.additionalQueryParams.toBuilder() + } + + fun licenseId(licenseId: String?) = apply { this.licenseId = licenseId } + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [endDate] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in the + * customer's timezone. + */ + fun endDate(endDate: LocalDate?) = apply { body.endDate(endDate) } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseDeactivateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseDeactivateParams = + LicenseDeactivateParams( + licenseId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of() + ) : this(endDate, mutableMapOf()) + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in the + * customer's timezone. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + endDate = body.endDate + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The date to deactivate the license. If not provided, defaults to end of day today in + * the customer's timezone. + */ + fun endDate(endDate: LocalDate?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(endDate, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + endDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (endDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + endDate == other.endDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{endDate=$endDate, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseDeactivateParams && + licenseId == other.licenseId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(licenseId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseDeactivateParams{licenseId=$licenseId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt new file mode 100644 index 000000000..654d5e5ba --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseDeactivateResponse.kt @@ -0,0 +1,569 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseDeactivateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseDeactivateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseDeactivateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseDeactivateResponse: LicenseDeactivateResponse) = apply { + id = licenseDeactivateResponse.id + endDate = licenseDeactivateResponse.endDate + externalLicenseId = licenseDeactivateResponse.externalLicenseId + licenseTypeId = licenseDeactivateResponse.licenseTypeId + startDate = licenseDeactivateResponse.startDate + status = licenseDeactivateResponse.status + subscriptionId = licenseDeactivateResponse.subscriptionId + additionalProperties = licenseDeactivateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseDeactivateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseDeactivateResponse = + LicenseDeactivateResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseDeactivateResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseDeactivateResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseDeactivateResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt new file mode 100644 index 000000000..83028e31c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParams.kt @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +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 com.withorb.api.core.toImmutable +import java.time.LocalDate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns usage and remaining credits for a license identified by its external license ID. + * + * Date range defaults to the current billing period if not specified. + */ +class LicenseExternalLicenseGetUsageParams +private constructor( + private val externalLicenseId: String?, + private val licenseTypeId: String, + private val subscriptionId: String, + private val cursor: String?, + private val endDate: LocalDate?, + private val groupBy: List?, + private val limit: Long?, + private val startDate: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun externalLicenseId(): Optional = Optional.ofNullable(externalLicenseId) + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(): String = licenseTypeId + + /** The subscription ID to get license usage for. */ + fun subscriptionId(): String = subscriptionId + + /** Pagination cursor from a previous request. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. */ + fun endDate(): Optional = Optional.ofNullable(endDate) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(): Optional> = Optional.ofNullable(groupBy) + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing period. + */ + fun startDate(): Optional = Optional.ofNullable(startDate) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseExternalLicenseGetUsageParams]. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseExternalLicenseGetUsageParams]. */ + class Builder internal constructor() { + + private var externalLicenseId: String? = null + private var licenseTypeId: String? = null + private var subscriptionId: String? = null + private var cursor: String? = null + private var endDate: LocalDate? = null + private var groupBy: MutableList? = null + private var limit: Long? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + licenseExternalLicenseGetUsageParams: LicenseExternalLicenseGetUsageParams + ) = apply { + externalLicenseId = licenseExternalLicenseGetUsageParams.externalLicenseId + licenseTypeId = licenseExternalLicenseGetUsageParams.licenseTypeId + subscriptionId = licenseExternalLicenseGetUsageParams.subscriptionId + cursor = licenseExternalLicenseGetUsageParams.cursor + endDate = licenseExternalLicenseGetUsageParams.endDate + groupBy = licenseExternalLicenseGetUsageParams.groupBy?.toMutableList() + limit = licenseExternalLicenseGetUsageParams.limit + startDate = licenseExternalLicenseGetUsageParams.startDate + additionalHeaders = licenseExternalLicenseGetUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = + licenseExternalLicenseGetUsageParams.additionalQueryParams.toBuilder() + } + + fun externalLicenseId(externalLicenseId: String?) = apply { + this.externalLicenseId = externalLicenseId + } + + /** Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(licenseTypeId: String) = apply { this.licenseTypeId = licenseTypeId } + + /** The subscription ID to get license usage for. */ + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + /** Pagination cursor from a previous request. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + */ + fun endDate(endDate: LocalDate?) = apply { this.endDate = endDate } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(groupBy: List?) = apply { this.groupBy = groupBy?.toMutableList() } + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional>) = groupBy(groupBy.getOrNull()) + + /** + * Adds a single [String] to [Builder.groupBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupBy(groupBy: String) = apply { + this.groupBy = (this.groupBy ?: mutableListOf()).apply { add(groupBy) } + } + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing + * period. + */ + fun startDate(startDate: LocalDate?) = apply { this.startDate = startDate } + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseExternalLicenseGetUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseExternalLicenseGetUsageParams = + LicenseExternalLicenseGetUsageParams( + externalLicenseId, + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + cursor, + endDate, + groupBy?.toImmutable(), + limit, + startDate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> externalLicenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("license_type_id", licenseTypeId) + put("subscription_id", subscriptionId) + cursor?.let { put("cursor", it) } + endDate?.let { put("end_date", it.toString()) } + groupBy?.forEach { put("group_by[]", it) } + limit?.let { put("limit", it.toString()) } + startDate?.let { put("start_date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseExternalLicenseGetUsageParams && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + endDate == other.endDate && + groupBy == other.groupBy && + limit == other.limit && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + externalLicenseId, + licenseTypeId, + subscriptionId, + cursor, + endDate, + groupBy, + limit, + startDate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseExternalLicenseGetUsageParams{externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, cursor=$cursor, endDate=$endDate, groupBy=$groupBy, limit=$limit, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt new file mode 100644 index 000000000..77a029893 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponse.kt @@ -0,0 +1,980 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseExternalLicenseGetUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseExternalLicenseGetUsageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseExternalLicenseGetUsageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + licenseExternalLicenseGetUsageResponse: LicenseExternalLicenseGetUsageResponse + ) = apply { + data = licenseExternalLicenseGetUsageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseExternalLicenseGetUsageResponse.paginationMetadata + additionalProperties = + licenseExternalLicenseGetUsageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseExternalLicenseGetUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseExternalLicenseGetUsageResponse = + LicenseExternalLicenseGetUsageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseExternalLicenseGetUsageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The LicenseUsage resource represents usage and remaining credits for a license over a date + * range. + * + * When grouped by 'day' only, license_id and external_license_id will be null as the data is + * aggregated across all licenses. + */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocatedCredits: JsonField, + private val consumedCredits: JsonField, + private val endDate: JsonField, + private val licenseTypeId: JsonField, + private val pricingUnit: JsonField, + private val remainingCredits: JsonField, + private val startDate: JsonField, + private val subscriptionId: JsonField, + private val allocationEligibleCredits: JsonField, + private val externalLicenseId: JsonField, + private val licenseId: JsonField, + private val sharedPoolCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocated_credits") + @ExcludeMissing + allocatedCredits: JsonField = JsonMissing.of(), + @JsonProperty("consumed_credits") + @ExcludeMissing + consumedCredits: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("pricing_unit") + @ExcludeMissing + pricingUnit: JsonField = JsonMissing.of(), + @JsonProperty("remaining_credits") + @ExcludeMissing + remainingCredits: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + allocationEligibleCredits: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_id") + @ExcludeMissing + licenseId: JsonField = JsonMissing.of(), + @JsonProperty("shared_pool_credits") + @ExcludeMissing + sharedPoolCredits: JsonField = JsonMissing.of(), + ) : this( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + mutableMapOf(), + ) + + /** + * The total credits allocated to this license for the 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 allocatedCredits(): Double = allocatedCredits.getRequired("allocated_credits") + + /** + * The credits consumed by this license for the 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 consumedCredits(): Double = consumedCredits.getRequired("consumed_credits") + + /** + * The end date of the usage 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 endDate(): LocalDate = endDate.getRequired("end_date") + + /** + * The unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * The pricing unit for the credits (e.g., 'credits'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pricingUnit(): String = pricingUnit.getRequired("pricing_unit") + + /** + * The remaining credits available for this license (allocated - consumed). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun remainingCredits(): Double = remainingCredits.getRequired("remaining_credits") + + /** + * The start date of the usage 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 startDate(): LocalDate = startDate.getRequired("start_date") + + /** + * The unique identifier for the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationEligibleCredits(): Optional = + allocationEligibleCredits.getOptional("allocation_eligible_credits") + + /** + * The external identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalLicenseId(): Optional = + externalLicenseId.getOptional("external_license_id") + + /** + * The unique identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseId(): Optional = licenseId.getOptional("license_id") + + /** + * Credits consumed while the license was inactive (draws from shared pool, not individual + * allocation). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedPoolCredits(): Optional = + sharedPoolCredits.getOptional("shared_pool_credits") + + /** + * Returns the raw JSON value of [allocatedCredits]. + * + * Unlike [allocatedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocated_credits") + @ExcludeMissing + fun _allocatedCredits(): JsonField = allocatedCredits + + /** + * Returns the raw JSON value of [consumedCredits]. + * + * Unlike [consumedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumed_credits") + @ExcludeMissing + fun _consumedCredits(): JsonField = consumedCredits + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [pricingUnit]. + * + * Unlike [pricingUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_unit") + @ExcludeMissing + fun _pricingUnit(): JsonField = pricingUnit + + /** + * Returns the raw JSON value of [remainingCredits]. + * + * Unlike [remainingCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remaining_credits") + @ExcludeMissing + fun _remainingCredits(): JsonField = remainingCredits + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocationEligibleCredits]. + * + * Unlike [allocationEligibleCredits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + fun _allocationEligibleCredits(): JsonField = allocationEligibleCredits + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseId]. + * + * Unlike [licenseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_id") @ExcludeMissing fun _licenseId(): JsonField = licenseId + + /** + * Returns the raw JSON value of [sharedPoolCredits]. + * + * Unlike [sharedPoolCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_pool_credits") + @ExcludeMissing + fun _sharedPoolCredits(): JsonField = sharedPoolCredits + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var allocatedCredits: JsonField? = null + private var consumedCredits: JsonField? = null + private var endDate: JsonField? = null + private var licenseTypeId: JsonField? = null + private var pricingUnit: JsonField? = null + private var remainingCredits: JsonField? = null + private var startDate: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocationEligibleCredits: JsonField = JsonMissing.of() + private var externalLicenseId: JsonField = JsonMissing.of() + private var licenseId: JsonField = JsonMissing.of() + private var sharedPoolCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + allocatedCredits = data.allocatedCredits + consumedCredits = data.consumedCredits + endDate = data.endDate + licenseTypeId = data.licenseTypeId + pricingUnit = data.pricingUnit + remainingCredits = data.remainingCredits + startDate = data.startDate + subscriptionId = data.subscriptionId + allocationEligibleCredits = data.allocationEligibleCredits + externalLicenseId = data.externalLicenseId + licenseId = data.licenseId + sharedPoolCredits = data.sharedPoolCredits + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The total credits allocated to this license for the period. */ + fun allocatedCredits(allocatedCredits: Double) = + allocatedCredits(JsonField.of(allocatedCredits)) + + /** + * Sets [Builder.allocatedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocatedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocatedCredits(allocatedCredits: JsonField) = apply { + this.allocatedCredits = allocatedCredits + } + + /** The credits consumed by this license for the period. */ + fun consumedCredits(consumedCredits: Double) = + consumedCredits(JsonField.of(consumedCredits)) + + /** + * Sets [Builder.consumedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.consumedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumedCredits(consumedCredits: JsonField) = apply { + this.consumedCredits = consumedCredits + } + + /** The end date of the usage period. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The unique identifier for the license type. */ + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** The pricing unit for the credits (e.g., 'credits'). */ + fun pricingUnit(pricingUnit: String) = pricingUnit(JsonField.of(pricingUnit)) + + /** + * Sets [Builder.pricingUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnit(pricingUnit: JsonField) = apply { + this.pricingUnit = pricingUnit + } + + /** The remaining credits available for this license (allocated - consumed). */ + fun remainingCredits(remainingCredits: Double) = + remainingCredits(JsonField.of(remainingCredits)) + + /** + * Sets [Builder.remainingCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.remainingCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remainingCredits(remainingCredits: JsonField) = apply { + this.remainingCredits = remainingCredits + } + + /** The start date of the usage period. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The unique identifier for the subscription. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double?) = + allocationEligibleCredits(JsonField.ofNullable(allocationEligibleCredits)) + + /** + * Alias for [Builder.allocationEligibleCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double) = + allocationEligibleCredits(allocationEligibleCredits as Double?) + + /** + * Alias for calling [Builder.allocationEligibleCredits] with + * `allocationEligibleCredits.orElse(null)`. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Optional) = + allocationEligibleCredits(allocationEligibleCredits.getOrNull()) + + /** + * Sets [Builder.allocationEligibleCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationEligibleCredits] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocationEligibleCredits(allocationEligibleCredits: JsonField) = apply { + this.allocationEligibleCredits = allocationEligibleCredits + } + + /** The external identifier for the license. Null when grouped by day only. */ + fun externalLicenseId(externalLicenseId: String?) = + externalLicenseId(JsonField.ofNullable(externalLicenseId)) + + /** + * Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. + */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The unique identifier for the license. Null when grouped by day only. */ + fun licenseId(licenseId: String?) = licenseId(JsonField.ofNullable(licenseId)) + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** + * Sets [Builder.licenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseId(licenseId: JsonField) = apply { this.licenseId = licenseId } + + /** + * Credits consumed while the license was inactive (draws from shared pool, not + * individual allocation). + */ + fun sharedPoolCredits(sharedPoolCredits: Double?) = + sharedPoolCredits(JsonField.ofNullable(sharedPoolCredits)) + + /** + * Alias for [Builder.sharedPoolCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sharedPoolCredits(sharedPoolCredits: Double) = + sharedPoolCredits(sharedPoolCredits as Double?) + + /** + * Alias for calling [Builder.sharedPoolCredits] with `sharedPoolCredits.orElse(null)`. + */ + fun sharedPoolCredits(sharedPoolCredits: Optional) = + sharedPoolCredits(sharedPoolCredits.getOrNull()) + + /** + * Sets [Builder.sharedPoolCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPoolCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPoolCredits(sharedPoolCredits: JsonField) = apply { + this.sharedPoolCredits = sharedPoolCredits + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("allocatedCredits", allocatedCredits), + checkRequired("consumedCredits", consumedCredits), + checkRequired("endDate", endDate), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("pricingUnit", pricingUnit), + checkRequired("remainingCredits", remainingCredits), + checkRequired("startDate", startDate), + checkRequired("subscriptionId", subscriptionId), + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Data = apply { + if (validated) { + return@apply + } + + allocatedCredits() + consumedCredits() + endDate() + licenseTypeId() + pricingUnit() + remainingCredits() + startDate() + subscriptionId() + allocationEligibleCredits() + externalLicenseId() + licenseId() + sharedPoolCredits() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allocatedCredits.asKnown().isPresent) 1 else 0) + + (if (consumedCredits.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (pricingUnit.asKnown().isPresent) 1 else 0) + + (if (remainingCredits.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (allocationEligibleCredits.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseId.asKnown().isPresent) 1 else 0) + + (if (sharedPoolCredits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + allocatedCredits == other.allocatedCredits && + consumedCredits == other.consumedCredits && + endDate == other.endDate && + licenseTypeId == other.licenseTypeId && + pricingUnit == other.pricingUnit && + remainingCredits == other.remainingCredits && + startDate == other.startDate && + subscriptionId == other.subscriptionId && + allocationEligibleCredits == other.allocationEligibleCredits && + externalLicenseId == other.externalLicenseId && + licenseId == other.licenseId && + sharedPoolCredits == other.sharedPoolCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{allocatedCredits=$allocatedCredits, consumedCredits=$consumedCredits, endDate=$endDate, licenseTypeId=$licenseTypeId, pricingUnit=$pricingUnit, remainingCredits=$remainingCredits, startDate=$startDate, subscriptionId=$subscriptionId, allocationEligibleCredits=$allocationEligibleCredits, externalLicenseId=$externalLicenseId, licenseId=$licenseId, sharedPoolCredits=$sharedPoolCredits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseExternalLicenseGetUsageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseExternalLicenseGetUsageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt new file mode 100644 index 000000000..9a7b44475 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPage.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +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.LicenseService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see LicenseService.list */ +class LicenseListPage +private constructor( + private val service: LicenseService, + private val params: LicenseListParams, + private val response: LicenseListPageResponse, +) : Page { + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.paginationMetadata + */ + fun paginationMetadata(): Optional = + response._paginationMetadata().getOptional("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + + fun nextPageParams(): LicenseListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): LicenseListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): LicenseListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListPage]. */ + class Builder internal constructor() { + + private var service: LicenseService? = null + private var params: LicenseListParams? = null + private var response: LicenseListPageResponse? = null + + @JvmSynthetic + internal fun from(licenseListPage: LicenseListPage) = apply { + service = licenseListPage.service + params = licenseListPage.params + response = licenseListPage.response + } + + fun service(service: LicenseService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListPage = + LicenseListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "LicenseListPage{service=$service, params=$params, response=$response}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt new file mode 100644 index 000000000..e0d605def --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageAsync.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +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.LicenseServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see LicenseServiceAsync.list */ +class LicenseListPageAsync +private constructor( + private val service: LicenseServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: LicenseListParams, + private val response: LicenseListPageResponse, +) : PageAsync { + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [LicenseListPageResponse], but gracefully handles missing data. + * + * @see LicenseListPageResponse.paginationMetadata + */ + fun paginationMetadata(): Optional = + response._paginationMetadata().getOptional("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + + fun nextPageParams(): LicenseListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): LicenseListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListPageAsync]. */ + class Builder internal constructor() { + + private var service: LicenseServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: LicenseListParams? = null + private var response: LicenseListPageResponse? = null + + @JvmSynthetic + internal fun from(licenseListPageAsync: LicenseListPageAsync) = apply { + service = licenseListPageAsync.service + streamHandlerExecutor = licenseListPageAsync.streamHandlerExecutor + params = licenseListPageAsync.params + response = licenseListPageAsync.response + } + + fun service(service: LicenseServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListPageAsync = + LicenseListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "LicenseListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt new file mode 100644 index 000000000..8a24a1496 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListPageResponse.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class LicenseListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseListPageResponse: LicenseListPageResponse) = apply { + data = licenseListPageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseListPageResponse.paginationMetadata + additionalProperties = licenseListPageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseListResponse] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: LicenseListResponse) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListPageResponse = + LicenseListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseListPageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt new file mode 100644 index 000000000..350823e7d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListParams.kt @@ -0,0 +1,436 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +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 +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This endpoint returns a list of all licenses for a subscription. */ +class LicenseListParams +private constructor( + private val subscriptionId: String, + private val cursor: String?, + private val externalLicenseId: String?, + private val licenseTypeId: String?, + private val limit: Long?, + private val status: Status?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun subscriptionId(): String = subscriptionId + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + fun externalLicenseId(): Optional = Optional.ofNullable(externalLicenseId) + + fun licenseTypeId(): Optional = Optional.ofNullable(licenseTypeId) + + /** The number of items to fetch. Defaults to 20. */ + fun limit(): Optional = Optional.ofNullable(limit) + + fun status(): Optional = Optional.ofNullable(status) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListParams]. */ + class Builder internal constructor() { + + private var subscriptionId: String? = null + private var cursor: String? = null + private var externalLicenseId: String? = null + private var licenseTypeId: String? = null + private var limit: Long? = null + private var status: Status? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseListParams: LicenseListParams) = apply { + subscriptionId = licenseListParams.subscriptionId + cursor = licenseListParams.cursor + externalLicenseId = licenseListParams.externalLicenseId + licenseTypeId = licenseListParams.licenseTypeId + limit = licenseListParams.limit + status = licenseListParams.status + additionalHeaders = licenseListParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseListParams.additionalQueryParams.toBuilder() + } + + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun externalLicenseId(externalLicenseId: String?) = apply { + this.externalLicenseId = externalLicenseId + } + + /** Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + fun licenseTypeId(licenseTypeId: String?) = apply { this.licenseTypeId = licenseTypeId } + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** The number of items to fetch. Defaults to 20. */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseListParams]. + * + * 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(): LicenseListParams = + LicenseListParams( + checkRequired("subscriptionId", subscriptionId), + cursor, + externalLicenseId, + licenseTypeId, + limit, + status, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("subscription_id", subscriptionId) + cursor?.let { put("cursor", it) } + externalLicenseId?.let { put("external_license_id", it) } + licenseTypeId?.let { put("license_type_id", it) } + limit?.let { put("limit", it.toString()) } + status?.let { put("status", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListParams && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + limit == other.limit && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + subscriptionId, + cursor, + externalLicenseId, + licenseTypeId, + limit, + status, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseListParams{subscriptionId=$subscriptionId, cursor=$cursor, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, limit=$limit, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt new file mode 100644 index 000000000..3452bb9ad --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseListResponse.kt @@ -0,0 +1,569 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseListResponse: LicenseListResponse) = apply { + id = licenseListResponse.id + endDate = licenseListResponse.endDate + externalLicenseId = licenseListResponse.externalLicenseId + licenseTypeId = licenseListResponse.licenseTypeId + startDate = licenseListResponse.startDate + status = licenseListResponse.status + subscriptionId = licenseListResponse.subscriptionId + additionalProperties = licenseListResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseListResponse = + LicenseListResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseListResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseListResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseListResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt new file mode 100644 index 000000000..0f9be2744 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParams.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +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 license given an external license identifier. */ +class LicenseRetrieveByExternalIdParams +private constructor( + private val externalLicenseId: String?, + private val licenseTypeId: String, + private val subscriptionId: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun externalLicenseId(): Optional = Optional.ofNullable(externalLicenseId) + + /** The ID of the license type to fetch the license for. */ + fun licenseTypeId(): String = licenseTypeId + + /** The ID of the subscription to fetch the license for. */ + fun subscriptionId(): String = subscriptionId + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseRetrieveByExternalIdParams]. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveByExternalIdParams]. */ + class Builder internal constructor() { + + private var externalLicenseId: String? = null + private var licenseTypeId: String? = null + private var subscriptionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseRetrieveByExternalIdParams: LicenseRetrieveByExternalIdParams) = + apply { + externalLicenseId = licenseRetrieveByExternalIdParams.externalLicenseId + licenseTypeId = licenseRetrieveByExternalIdParams.licenseTypeId + subscriptionId = licenseRetrieveByExternalIdParams.subscriptionId + additionalHeaders = licenseRetrieveByExternalIdParams.additionalHeaders.toBuilder() + additionalQueryParams = + licenseRetrieveByExternalIdParams.additionalQueryParams.toBuilder() + } + + fun externalLicenseId(externalLicenseId: String?) = apply { + this.externalLicenseId = externalLicenseId + } + + /** Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** The ID of the license type to fetch the license for. */ + fun licenseTypeId(licenseTypeId: String) = apply { this.licenseTypeId = licenseTypeId } + + /** The ID of the subscription to fetch the license for. */ + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseRetrieveByExternalIdParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseRetrieveByExternalIdParams = + LicenseRetrieveByExternalIdParams( + externalLicenseId, + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> externalLicenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("license_type_id", licenseTypeId) + put("subscription_id", subscriptionId) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveByExternalIdParams && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + externalLicenseId, + licenseTypeId, + subscriptionId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseRetrieveByExternalIdParams{externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt new file mode 100644 index 000000000..d573566b0 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponse.kt @@ -0,0 +1,573 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseRetrieveByExternalIdResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseRetrieveByExternalIdResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveByExternalIdResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + licenseRetrieveByExternalIdResponse: LicenseRetrieveByExternalIdResponse + ) = apply { + id = licenseRetrieveByExternalIdResponse.id + endDate = licenseRetrieveByExternalIdResponse.endDate + externalLicenseId = licenseRetrieveByExternalIdResponse.externalLicenseId + licenseTypeId = licenseRetrieveByExternalIdResponse.licenseTypeId + startDate = licenseRetrieveByExternalIdResponse.startDate + status = licenseRetrieveByExternalIdResponse.status + subscriptionId = licenseRetrieveByExternalIdResponse.subscriptionId + additionalProperties = + licenseRetrieveByExternalIdResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseRetrieveByExternalIdResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseRetrieveByExternalIdResponse = + LicenseRetrieveByExternalIdResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseRetrieveByExternalIdResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveByExternalIdResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseRetrieveByExternalIdResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt new file mode 100644 index 000000000..c52fd1280 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveParams.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +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 license given an identifier. */ +class LicenseRetrieveParams +private constructor( + private val licenseId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseId(): Optional = Optional.ofNullable(licenseId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LicenseRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveParams]. */ + class Builder internal constructor() { + + private var licenseId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseRetrieveParams: LicenseRetrieveParams) = apply { + licenseId = licenseRetrieveParams.licenseId + additionalHeaders = licenseRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseRetrieveParams.additionalQueryParams.toBuilder() + } + + fun licenseId(licenseId: String?) = apply { this.licenseId = licenseId } + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseRetrieveParams = + LicenseRetrieveParams( + licenseId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveParams && + licenseId == other.licenseId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(licenseId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseRetrieveParams{licenseId=$licenseId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt new file mode 100644 index 000000000..76f36b536 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseRetrieveResponse.kt @@ -0,0 +1,569 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val endDate: JsonField, + private val externalLicenseId: JsonField, + private val licenseTypeId: JsonField, + private val startDate: JsonField, + private val status: JsonField, + private val subscriptionId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + ) : this( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalLicenseId(): String = externalLicenseId.getRequired("external_license_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var endDate: JsonField? = null + private var externalLicenseId: JsonField? = null + private var licenseTypeId: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var subscriptionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseRetrieveResponse: LicenseRetrieveResponse) = apply { + id = licenseRetrieveResponse.id + endDate = licenseRetrieveResponse.endDate + externalLicenseId = licenseRetrieveResponse.externalLicenseId + licenseTypeId = licenseRetrieveResponse.licenseTypeId + startDate = licenseRetrieveResponse.startDate + status = licenseRetrieveResponse.status + subscriptionId = licenseRetrieveResponse.subscriptionId + additionalProperties = licenseRetrieveResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalLicenseId(externalLicenseId: String) = + externalLicenseId(JsonField.of(externalLicenseId)) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun subscriptionId(subscriptionId: String) = subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .endDate() + * .externalLicenseId() + * .licenseTypeId() + * .startDate() + * .status() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseRetrieveResponse = + LicenseRetrieveResponse( + checkRequired("id", id), + checkRequired("endDate", endDate), + checkRequired("externalLicenseId", externalLicenseId), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("subscriptionId", subscriptionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + endDate() + externalLicenseId() + licenseTypeId() + startDate() + status().validate() + subscriptionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val INACTIVE = of("inactive") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + INACTIVE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw OrbInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseRetrieveResponse && + id == other.id && + endDate == other.endDate && + externalLicenseId == other.externalLicenseId && + licenseTypeId == other.licenseTypeId && + startDate == other.startDate && + status == other.status && + subscriptionId == other.subscriptionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + endDate, + externalLicenseId, + licenseTypeId, + startDate, + status, + subscriptionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseRetrieveResponse{id=$id, endDate=$endDate, externalLicenseId=$externalLicenseId, licenseTypeId=$licenseTypeId, startDate=$startDate, status=$status, subscriptionId=$subscriptionId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt new file mode 100644 index 000000000..5def6d84d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateParams.kt @@ -0,0 +1,514 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.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 + +/** + * This endpoint is used to create a new license type. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ +class LicenseTypeCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = body.groupingKey() + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _groupingKey(): JsonField = body._groupingKey() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeCreateParams]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseTypeCreateParams: LicenseTypeCreateParams) = apply { + body = licenseTypeCreateParams.body.toBuilder() + additionalHeaders = licenseTypeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseTypeCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [groupingKey] + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = apply { body.groupingKey(groupingKey) } + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { body.groupingKey(groupingKey) } + + /** The name of the license type. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseTypeCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeCreateParams = + LicenseTypeCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(groupingKey, name, mutableMapOf()) + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + groupingKey = body.groupingKey + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseTypeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt new file mode 100644 index 000000000..bd0d9bfe6 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeCreateResponse.kt @@ -0,0 +1,267 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseTypeCreateResponse: LicenseTypeCreateResponse) = apply { + id = licenseTypeCreateResponse.id + groupingKey = licenseTypeCreateResponse.groupingKey + name = licenseTypeCreateResponse.name + additionalProperties = licenseTypeCreateResponse.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { this.groupingKey = groupingKey } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseTypeCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeCreateResponse = + LicenseTypeCreateResponse( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseTypeCreateResponse = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeCreateResponse && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeCreateResponse{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt new file mode 100644 index 000000000..56cf27b4a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPage.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +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.LicenseTypeService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see LicenseTypeService.list */ +class LicenseTypeListPage +private constructor( + private val service: LicenseTypeService, + private val params: LicenseTypeListParams, + private val response: LicenseTypeListPageResponse, +) : Page { + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.paginationMetadata + */ + fun paginationMetadata(): Optional = + response._paginationMetadata().getOptional("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + + fun nextPageParams(): LicenseTypeListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): LicenseTypeListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): LicenseTypeListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseTypeListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListPage]. */ + class Builder internal constructor() { + + private var service: LicenseTypeService? = null + private var params: LicenseTypeListParams? = null + private var response: LicenseTypeListPageResponse? = null + + @JvmSynthetic + internal fun from(licenseTypeListPage: LicenseTypeListPage) = apply { + service = licenseTypeListPage.service + params = licenseTypeListPage.params + response = licenseTypeListPage.response + } + + fun service(service: LicenseTypeService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseTypeListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseTypeListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseTypeListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListPage = + LicenseTypeListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "LicenseTypeListPage{service=$service, params=$params, response=$response}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt new file mode 100644 index 000000000..ba5b17e26 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageAsync.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +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.LicenseTypeServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see LicenseTypeServiceAsync.list */ +class LicenseTypeListPageAsync +private constructor( + private val service: LicenseTypeServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: LicenseTypeListParams, + private val response: LicenseTypeListPageResponse, +) : PageAsync { + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [LicenseTypeListPageResponse], but gracefully handles missing data. + * + * @see LicenseTypeListPageResponse.paginationMetadata + */ + fun paginationMetadata(): Optional = + response._paginationMetadata().getOptional("pagination_metadata") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + + fun nextPageParams(): LicenseTypeListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): LicenseTypeListParams = params + + /** The response that this page was parsed from. */ + fun response(): LicenseTypeListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListPageAsync]. */ + class Builder internal constructor() { + + private var service: LicenseTypeServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: LicenseTypeListParams? = null + private var response: LicenseTypeListPageResponse? = null + + @JvmSynthetic + internal fun from(licenseTypeListPageAsync: LicenseTypeListPageAsync) = apply { + service = licenseTypeListPageAsync.service + streamHandlerExecutor = licenseTypeListPageAsync.streamHandlerExecutor + params = licenseTypeListPageAsync.params + response = licenseTypeListPageAsync.response + } + + fun service(service: LicenseTypeServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: LicenseTypeListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: LicenseTypeListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [LicenseTypeListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListPageAsync = + LicenseTypeListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "LicenseTypeListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt new file mode 100644 index 000000000..c9b239ebc --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListPageResponse.kt @@ -0,0 +1,247 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class LicenseTypeListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseTypeListPageResponse: LicenseTypeListPageResponse) = apply { + data = licenseTypeListPageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseTypeListPageResponse.paginationMetadata + additionalProperties = licenseTypeListPageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [LicenseTypeListResponse] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: LicenseTypeListResponse) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseTypeListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListPageResponse = + LicenseTypeListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseTypeListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListPageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeListPageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt new file mode 100644 index 000000000..2d82ad755 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +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 list of all license types configured for the account, ordered in + * ascending order by creation time. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ +class LicenseTypeListParams +private constructor( + private val cursor: String?, + private val limit: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** The number of items to fetch. Defaults to 20. */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseTypeListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LicenseTypeListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var limit: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseTypeListParams: LicenseTypeListParams) = apply { + cursor = licenseTypeListParams.cursor + limit = licenseTypeListParams.limit + additionalHeaders = licenseTypeListParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseTypeListParams.additionalQueryParams.toBuilder() + } + + /** + * Cursor for pagination. This can be populated by the `next_cursor` value returned from the + * initial request. + */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** The number of items to fetch. Defaults to 20. */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseTypeListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseTypeListParams = + LicenseTypeListParams( + cursor, + limit, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListParams && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseTypeListParams{cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt new file mode 100644 index 000000000..1cbfa5087 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeListResponse.kt @@ -0,0 +1,267 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseTypeListResponse: LicenseTypeListResponse) = apply { + id = licenseTypeListResponse.id + groupingKey = licenseTypeListResponse.groupingKey + name = licenseTypeListResponse.name + additionalProperties = licenseTypeListResponse.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { this.groupingKey = groupingKey } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseTypeListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeListResponse = + LicenseTypeListResponse( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseTypeListResponse = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeListResponse && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeListResponse{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt new file mode 100644 index 000000000..958de0d5f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveParams.kt @@ -0,0 +1,202 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +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 license type identified by its license_type_id. + * + * Use this endpoint to retrieve details about a specific license type, including its name and + * grouping key. + */ +class LicenseTypeRetrieveParams +private constructor( + private val licenseTypeId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseTypeId(): Optional = Optional.ofNullable(licenseTypeId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseTypeRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeRetrieveParams]. */ + class Builder internal constructor() { + + private var licenseTypeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseTypeRetrieveParams: LicenseTypeRetrieveParams) = apply { + licenseTypeId = licenseTypeRetrieveParams.licenseTypeId + additionalHeaders = licenseTypeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseTypeRetrieveParams.additionalQueryParams.toBuilder() + } + + fun licenseTypeId(licenseTypeId: String?) = apply { this.licenseTypeId = licenseTypeId } + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseTypeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseTypeRetrieveParams = + LicenseTypeRetrieveParams( + licenseTypeId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseTypeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeRetrieveParams && + licenseTypeId == other.licenseTypeId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(licenseTypeId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LicenseTypeRetrieveParams{licenseTypeId=$licenseTypeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt new file mode 100644 index 000000000..e61c39fb1 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponse.kt @@ -0,0 +1,267 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkRequired +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseTypeRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseTypeRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseTypeRetrieveResponse: LicenseTypeRetrieveResponse) = apply { + id = licenseTypeRetrieveResponse.id + groupingKey = licenseTypeRetrieveResponse.groupingKey + name = licenseTypeRetrieveResponse.name + additionalProperties = licenseTypeRetrieveResponse.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupingKey(groupingKey: JsonField) = apply { this.groupingKey = groupingKey } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseTypeRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseTypeRetrieveResponse = + LicenseTypeRetrieveResponse( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseTypeRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseTypeRetrieveResponse && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, groupingKey, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseTypeRetrieveResponse{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt new file mode 100644 index 000000000..941a47d15 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParams.kt @@ -0,0 +1,341 @@ +// File generated from our OpenAPI spec by Stainless. + +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 com.withorb.api.core.toImmutable +import java.time.LocalDate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns usage and remaining credits for all licenses of a given type on a subscription. + * + * Date range defaults to the current billing period if not specified. + */ +class LicenseUsageGetAllUsageParams +private constructor( + private val licenseTypeId: String, + private val subscriptionId: String, + private val cursor: String?, + private val endDate: LocalDate?, + private val groupBy: List?, + private val limit: Long?, + private val startDate: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(): String = licenseTypeId + + /** The subscription ID to get license usage for. */ + fun subscriptionId(): String = subscriptionId + + /** Pagination cursor from a previous request. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. */ + fun endDate(): Optional = Optional.ofNullable(endDate) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(): Optional> = Optional.ofNullable(groupBy) + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing period. + */ + fun startDate(): Optional = Optional.ofNullable(startDate) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseUsageGetAllUsageParams]. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetAllUsageParams]. */ + class Builder internal constructor() { + + private var licenseTypeId: String? = null + private var subscriptionId: String? = null + private var cursor: String? = null + private var endDate: LocalDate? = null + private var groupBy: MutableList? = null + private var limit: Long? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseUsageGetAllUsageParams: LicenseUsageGetAllUsageParams) = apply { + licenseTypeId = licenseUsageGetAllUsageParams.licenseTypeId + subscriptionId = licenseUsageGetAllUsageParams.subscriptionId + cursor = licenseUsageGetAllUsageParams.cursor + endDate = licenseUsageGetAllUsageParams.endDate + groupBy = licenseUsageGetAllUsageParams.groupBy?.toMutableList() + limit = licenseUsageGetAllUsageParams.limit + startDate = licenseUsageGetAllUsageParams.startDate + additionalHeaders = licenseUsageGetAllUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseUsageGetAllUsageParams.additionalQueryParams.toBuilder() + } + + /** The license type ID to filter licenses by. */ + fun licenseTypeId(licenseTypeId: String) = apply { this.licenseTypeId = licenseTypeId } + + /** The subscription ID to get license usage for. */ + fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + + /** Pagination cursor from a previous request. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + */ + fun endDate(endDate: LocalDate?) = apply { this.endDate = endDate } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(groupBy: List?) = apply { this.groupBy = groupBy?.toMutableList() } + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional>) = groupBy(groupBy.getOrNull()) + + /** + * Adds a single [String] to [Builder.groupBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupBy(groupBy: String) = apply { + this.groupBy = (this.groupBy ?: mutableListOf()).apply { add(groupBy) } + } + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing + * period. + */ + fun startDate(startDate: LocalDate?) = apply { this.startDate = startDate } + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseUsageGetAllUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .licenseTypeId() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseUsageGetAllUsageParams = + LicenseUsageGetAllUsageParams( + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("subscriptionId", subscriptionId), + cursor, + endDate, + groupBy?.toImmutable(), + limit, + startDate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("license_type_id", licenseTypeId) + put("subscription_id", subscriptionId) + cursor?.let { put("cursor", it) } + endDate?.let { put("end_date", it.toString()) } + groupBy?.forEach { put("group_by[]", it) } + limit?.let { put("limit", it.toString()) } + startDate?.let { put("start_date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetAllUsageParams && + licenseTypeId == other.licenseTypeId && + subscriptionId == other.subscriptionId && + cursor == other.cursor && + endDate == other.endDate && + groupBy == other.groupBy && + limit == other.limit && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + licenseTypeId, + subscriptionId, + cursor, + endDate, + groupBy, + limit, + startDate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseUsageGetAllUsageParams{licenseTypeId=$licenseTypeId, subscriptionId=$subscriptionId, cursor=$cursor, endDate=$endDate, groupBy=$groupBy, limit=$limit, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt new file mode 100644 index 000000000..f7d89298c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponse.kt @@ -0,0 +1,979 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseUsageGetAllUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [LicenseUsageGetAllUsageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetAllUsageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseUsageGetAllUsageResponse: LicenseUsageGetAllUsageResponse) = + apply { + data = licenseUsageGetAllUsageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseUsageGetAllUsageResponse.paginationMetadata + additionalProperties = + licenseUsageGetAllUsageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseUsageGetAllUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseUsageGetAllUsageResponse = + LicenseUsageGetAllUsageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseUsageGetAllUsageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The LicenseUsage resource represents usage and remaining credits for a license over a date + * range. + * + * When grouped by 'day' only, license_id and external_license_id will be null as the data is + * aggregated across all licenses. + */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocatedCredits: JsonField, + private val consumedCredits: JsonField, + private val endDate: JsonField, + private val licenseTypeId: JsonField, + private val pricingUnit: JsonField, + private val remainingCredits: JsonField, + private val startDate: JsonField, + private val subscriptionId: JsonField, + private val allocationEligibleCredits: JsonField, + private val externalLicenseId: JsonField, + private val licenseId: JsonField, + private val sharedPoolCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocated_credits") + @ExcludeMissing + allocatedCredits: JsonField = JsonMissing.of(), + @JsonProperty("consumed_credits") + @ExcludeMissing + consumedCredits: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("pricing_unit") + @ExcludeMissing + pricingUnit: JsonField = JsonMissing.of(), + @JsonProperty("remaining_credits") + @ExcludeMissing + remainingCredits: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + allocationEligibleCredits: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_id") + @ExcludeMissing + licenseId: JsonField = JsonMissing.of(), + @JsonProperty("shared_pool_credits") + @ExcludeMissing + sharedPoolCredits: JsonField = JsonMissing.of(), + ) : this( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + mutableMapOf(), + ) + + /** + * The total credits allocated to this license for the 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 allocatedCredits(): Double = allocatedCredits.getRequired("allocated_credits") + + /** + * The credits consumed by this license for the 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 consumedCredits(): Double = consumedCredits.getRequired("consumed_credits") + + /** + * The end date of the usage 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 endDate(): LocalDate = endDate.getRequired("end_date") + + /** + * The unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * The pricing unit for the credits (e.g., 'credits'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pricingUnit(): String = pricingUnit.getRequired("pricing_unit") + + /** + * The remaining credits available for this license (allocated - consumed). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun remainingCredits(): Double = remainingCredits.getRequired("remaining_credits") + + /** + * The start date of the usage 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 startDate(): LocalDate = startDate.getRequired("start_date") + + /** + * The unique identifier for the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationEligibleCredits(): Optional = + allocationEligibleCredits.getOptional("allocation_eligible_credits") + + /** + * The external identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalLicenseId(): Optional = + externalLicenseId.getOptional("external_license_id") + + /** + * The unique identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseId(): Optional = licenseId.getOptional("license_id") + + /** + * Credits consumed while the license was inactive (draws from shared pool, not individual + * allocation). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedPoolCredits(): Optional = + sharedPoolCredits.getOptional("shared_pool_credits") + + /** + * Returns the raw JSON value of [allocatedCredits]. + * + * Unlike [allocatedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocated_credits") + @ExcludeMissing + fun _allocatedCredits(): JsonField = allocatedCredits + + /** + * Returns the raw JSON value of [consumedCredits]. + * + * Unlike [consumedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumed_credits") + @ExcludeMissing + fun _consumedCredits(): JsonField = consumedCredits + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [pricingUnit]. + * + * Unlike [pricingUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_unit") + @ExcludeMissing + fun _pricingUnit(): JsonField = pricingUnit + + /** + * Returns the raw JSON value of [remainingCredits]. + * + * Unlike [remainingCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remaining_credits") + @ExcludeMissing + fun _remainingCredits(): JsonField = remainingCredits + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocationEligibleCredits]. + * + * Unlike [allocationEligibleCredits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + fun _allocationEligibleCredits(): JsonField = allocationEligibleCredits + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseId]. + * + * Unlike [licenseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_id") @ExcludeMissing fun _licenseId(): JsonField = licenseId + + /** + * Returns the raw JSON value of [sharedPoolCredits]. + * + * Unlike [sharedPoolCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_pool_credits") + @ExcludeMissing + fun _sharedPoolCredits(): JsonField = sharedPoolCredits + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var allocatedCredits: JsonField? = null + private var consumedCredits: JsonField? = null + private var endDate: JsonField? = null + private var licenseTypeId: JsonField? = null + private var pricingUnit: JsonField? = null + private var remainingCredits: JsonField? = null + private var startDate: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocationEligibleCredits: JsonField = JsonMissing.of() + private var externalLicenseId: JsonField = JsonMissing.of() + private var licenseId: JsonField = JsonMissing.of() + private var sharedPoolCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + allocatedCredits = data.allocatedCredits + consumedCredits = data.consumedCredits + endDate = data.endDate + licenseTypeId = data.licenseTypeId + pricingUnit = data.pricingUnit + remainingCredits = data.remainingCredits + startDate = data.startDate + subscriptionId = data.subscriptionId + allocationEligibleCredits = data.allocationEligibleCredits + externalLicenseId = data.externalLicenseId + licenseId = data.licenseId + sharedPoolCredits = data.sharedPoolCredits + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The total credits allocated to this license for the period. */ + fun allocatedCredits(allocatedCredits: Double) = + allocatedCredits(JsonField.of(allocatedCredits)) + + /** + * Sets [Builder.allocatedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocatedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocatedCredits(allocatedCredits: JsonField) = apply { + this.allocatedCredits = allocatedCredits + } + + /** The credits consumed by this license for the period. */ + fun consumedCredits(consumedCredits: Double) = + consumedCredits(JsonField.of(consumedCredits)) + + /** + * Sets [Builder.consumedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.consumedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumedCredits(consumedCredits: JsonField) = apply { + this.consumedCredits = consumedCredits + } + + /** The end date of the usage period. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The unique identifier for the license type. */ + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** The pricing unit for the credits (e.g., 'credits'). */ + fun pricingUnit(pricingUnit: String) = pricingUnit(JsonField.of(pricingUnit)) + + /** + * Sets [Builder.pricingUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnit(pricingUnit: JsonField) = apply { + this.pricingUnit = pricingUnit + } + + /** The remaining credits available for this license (allocated - consumed). */ + fun remainingCredits(remainingCredits: Double) = + remainingCredits(JsonField.of(remainingCredits)) + + /** + * Sets [Builder.remainingCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.remainingCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remainingCredits(remainingCredits: JsonField) = apply { + this.remainingCredits = remainingCredits + } + + /** The start date of the usage period. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The unique identifier for the subscription. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double?) = + allocationEligibleCredits(JsonField.ofNullable(allocationEligibleCredits)) + + /** + * Alias for [Builder.allocationEligibleCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double) = + allocationEligibleCredits(allocationEligibleCredits as Double?) + + /** + * Alias for calling [Builder.allocationEligibleCredits] with + * `allocationEligibleCredits.orElse(null)`. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Optional) = + allocationEligibleCredits(allocationEligibleCredits.getOrNull()) + + /** + * Sets [Builder.allocationEligibleCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationEligibleCredits] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocationEligibleCredits(allocationEligibleCredits: JsonField) = apply { + this.allocationEligibleCredits = allocationEligibleCredits + } + + /** The external identifier for the license. Null when grouped by day only. */ + fun externalLicenseId(externalLicenseId: String?) = + externalLicenseId(JsonField.ofNullable(externalLicenseId)) + + /** + * Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. + */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The unique identifier for the license. Null when grouped by day only. */ + fun licenseId(licenseId: String?) = licenseId(JsonField.ofNullable(licenseId)) + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** + * Sets [Builder.licenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseId(licenseId: JsonField) = apply { this.licenseId = licenseId } + + /** + * Credits consumed while the license was inactive (draws from shared pool, not + * individual allocation). + */ + fun sharedPoolCredits(sharedPoolCredits: Double?) = + sharedPoolCredits(JsonField.ofNullable(sharedPoolCredits)) + + /** + * Alias for [Builder.sharedPoolCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sharedPoolCredits(sharedPoolCredits: Double) = + sharedPoolCredits(sharedPoolCredits as Double?) + + /** + * Alias for calling [Builder.sharedPoolCredits] with `sharedPoolCredits.orElse(null)`. + */ + fun sharedPoolCredits(sharedPoolCredits: Optional) = + sharedPoolCredits(sharedPoolCredits.getOrNull()) + + /** + * Sets [Builder.sharedPoolCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPoolCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPoolCredits(sharedPoolCredits: JsonField) = apply { + this.sharedPoolCredits = sharedPoolCredits + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("allocatedCredits", allocatedCredits), + checkRequired("consumedCredits", consumedCredits), + checkRequired("endDate", endDate), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("pricingUnit", pricingUnit), + checkRequired("remainingCredits", remainingCredits), + checkRequired("startDate", startDate), + checkRequired("subscriptionId", subscriptionId), + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Data = apply { + if (validated) { + return@apply + } + + allocatedCredits() + consumedCredits() + endDate() + licenseTypeId() + pricingUnit() + remainingCredits() + startDate() + subscriptionId() + allocationEligibleCredits() + externalLicenseId() + licenseId() + sharedPoolCredits() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allocatedCredits.asKnown().isPresent) 1 else 0) + + (if (consumedCredits.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (pricingUnit.asKnown().isPresent) 1 else 0) + + (if (remainingCredits.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (allocationEligibleCredits.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseId.asKnown().isPresent) 1 else 0) + + (if (sharedPoolCredits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + allocatedCredits == other.allocatedCredits && + consumedCredits == other.consumedCredits && + endDate == other.endDate && + licenseTypeId == other.licenseTypeId && + pricingUnit == other.pricingUnit && + remainingCredits == other.remainingCredits && + startDate == other.startDate && + subscriptionId == other.subscriptionId && + allocationEligibleCredits == other.allocationEligibleCredits && + externalLicenseId == other.externalLicenseId && + licenseId == other.licenseId && + sharedPoolCredits == other.sharedPoolCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{allocatedCredits=$allocatedCredits, consumedCredits=$consumedCredits, endDate=$endDate, licenseTypeId=$licenseTypeId, pricingUnit=$pricingUnit, remainingCredits=$remainingCredits, startDate=$startDate, subscriptionId=$subscriptionId, allocationEligibleCredits=$allocationEligibleCredits, externalLicenseId=$externalLicenseId, licenseId=$licenseId, sharedPoolCredits=$sharedPoolCredits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetAllUsageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseUsageGetAllUsageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt new file mode 100644 index 000000000..8a1701ee0 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageParams.kt @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.Params +import com.withorb.api.core.http.Headers +import com.withorb.api.core.http.QueryParams +import com.withorb.api.core.toImmutable +import java.time.LocalDate +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns usage and remaining credits for a specific license over a date range. + * + * Date range defaults to the current billing period if not specified. + */ +class LicenseUsageGetUsageParams +private constructor( + private val licenseId: String?, + private val cursor: String?, + private val endDate: LocalDate?, + private val groupBy: List?, + private val limit: Long?, + private val startDate: LocalDate?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun licenseId(): Optional = Optional.ofNullable(licenseId) + + /** Pagination cursor from a previous request. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. */ + fun endDate(): Optional = Optional.ofNullable(endDate) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(): Optional> = Optional.ofNullable(groupBy) + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing period. + */ + fun startDate(): Optional = Optional.ofNullable(startDate) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LicenseUsageGetUsageParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [LicenseUsageGetUsageParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetUsageParams]. */ + class Builder internal constructor() { + + private var licenseId: String? = null + private var cursor: String? = null + private var endDate: LocalDate? = null + private var groupBy: MutableList? = null + private var limit: Long? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(licenseUsageGetUsageParams: LicenseUsageGetUsageParams) = apply { + licenseId = licenseUsageGetUsageParams.licenseId + cursor = licenseUsageGetUsageParams.cursor + endDate = licenseUsageGetUsageParams.endDate + groupBy = licenseUsageGetUsageParams.groupBy?.toMutableList() + limit = licenseUsageGetUsageParams.limit + startDate = licenseUsageGetUsageParams.startDate + additionalHeaders = licenseUsageGetUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = licenseUsageGetUsageParams.additionalQueryParams.toBuilder() + } + + fun licenseId(licenseId: String?) = apply { this.licenseId = licenseId } + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** Pagination cursor from a previous request. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + */ + fun endDate(endDate: LocalDate?) = apply { this.endDate = endDate } + + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + + /** + * How to group the results. Valid values: 'license', 'day'. Can be combined (e.g., + * 'license,day'). + */ + fun groupBy(groupBy: List?) = apply { this.groupBy = groupBy?.toMutableList() } + + /** Alias for calling [Builder.groupBy] with `groupBy.orElse(null)`. */ + fun groupBy(groupBy: Optional>) = groupBy(groupBy.getOrNull()) + + /** + * Adds a single [String] to [Builder.groupBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGroupBy(groupBy: String) = apply { + this.groupBy = (this.groupBy ?: mutableListOf()).apply { add(groupBy) } + } + + /** Maximum number of rows in the response data (default 20, max 100). */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Start date for the usage period (YYYY-MM-DD). Defaults to start of current billing + * period. + */ + fun startDate(startDate: LocalDate?) = apply { this.startDate = startDate } + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LicenseUsageGetUsageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LicenseUsageGetUsageParams = + LicenseUsageGetUsageParams( + licenseId, + cursor, + endDate, + groupBy?.toImmutable(), + limit, + startDate, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> licenseId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + endDate?.let { put("end_date", it.toString()) } + groupBy?.forEach { put("group_by[]", it) } + limit?.let { put("limit", it.toString()) } + startDate?.let { put("start_date", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetUsageParams && + licenseId == other.licenseId && + cursor == other.cursor && + endDate == other.endDate && + groupBy == other.groupBy && + limit == other.limit && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + licenseId, + cursor, + endDate, + groupBy, + limit, + startDate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "LicenseUsageGetUsageParams{licenseId=$licenseId, cursor=$cursor, endDate=$endDate, groupBy=$groupBy, limit=$limit, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt new file mode 100644 index 000000000..81d3568fa --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponse.kt @@ -0,0 +1,976 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LicenseUsageGetUsageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val paginationMetadata: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + paginationMetadata: JsonField = JsonMissing.of(), + ) : this(data, paginationMetadata, 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 data(): List = data.getRequired("data") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [paginationMetadata]. + * + * Unlike [paginationMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseUsageGetUsageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseUsageGetUsageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseUsageGetUsageResponse: LicenseUsageGetUsageResponse) = apply { + data = licenseUsageGetUsageResponse.data.map { it.toMutableList() } + paginationMetadata = licenseUsageGetUsageResponse.paginationMetadata + additionalProperties = licenseUsageGetUsageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + /** + * Sets [Builder.paginationMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.paginationMetadata] with a well-typed + * [PaginationMetadata] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paginationMetadata(paginationMetadata: JsonField) = apply { + this.paginationMetadata = paginationMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseUsageGetUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseUsageGetUsageResponse = + LicenseUsageGetUsageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): LicenseUsageGetUsageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paginationMetadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The LicenseUsage resource represents usage and remaining credits for a license over a date + * range. + * + * When grouped by 'day' only, license_id and external_license_id will be null as the data is + * aggregated across all licenses. + */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocatedCredits: JsonField, + private val consumedCredits: JsonField, + private val endDate: JsonField, + private val licenseTypeId: JsonField, + private val pricingUnit: JsonField, + private val remainingCredits: JsonField, + private val startDate: JsonField, + private val subscriptionId: JsonField, + private val allocationEligibleCredits: JsonField, + private val externalLicenseId: JsonField, + private val licenseId: JsonField, + private val sharedPoolCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocated_credits") + @ExcludeMissing + allocatedCredits: JsonField = JsonMissing.of(), + @JsonProperty("consumed_credits") + @ExcludeMissing + consumedCredits: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("pricing_unit") + @ExcludeMissing + pricingUnit: JsonField = JsonMissing.of(), + @JsonProperty("remaining_credits") + @ExcludeMissing + remainingCredits: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("subscription_id") + @ExcludeMissing + subscriptionId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + allocationEligibleCredits: JsonField = JsonMissing.of(), + @JsonProperty("external_license_id") + @ExcludeMissing + externalLicenseId: JsonField = JsonMissing.of(), + @JsonProperty("license_id") + @ExcludeMissing + licenseId: JsonField = JsonMissing.of(), + @JsonProperty("shared_pool_credits") + @ExcludeMissing + sharedPoolCredits: JsonField = JsonMissing.of(), + ) : this( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + mutableMapOf(), + ) + + /** + * The total credits allocated to this license for the 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 allocatedCredits(): Double = allocatedCredits.getRequired("allocated_credits") + + /** + * The credits consumed by this license for the 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 consumedCredits(): Double = consumedCredits.getRequired("consumed_credits") + + /** + * The end date of the usage 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 endDate(): LocalDate = endDate.getRequired("end_date") + + /** + * The unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun licenseTypeId(): String = licenseTypeId.getRequired("license_type_id") + + /** + * The pricing unit for the credits (e.g., 'credits'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pricingUnit(): String = pricingUnit.getRequired("pricing_unit") + + /** + * The remaining credits available for this license (allocated - consumed). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun remainingCredits(): Double = remainingCredits.getRequired("remaining_credits") + + /** + * The start date of the usage 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 startDate(): LocalDate = startDate.getRequired("start_date") + + /** + * The unique identifier for the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionId(): String = subscriptionId.getRequired("subscription_id") + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationEligibleCredits(): Optional = + allocationEligibleCredits.getOptional("allocation_eligible_credits") + + /** + * The external identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalLicenseId(): Optional = + externalLicenseId.getOptional("external_license_id") + + /** + * The unique identifier for the license. Null when grouped by day only. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseId(): Optional = licenseId.getOptional("license_id") + + /** + * Credits consumed while the license was inactive (draws from shared pool, not individual + * allocation). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedPoolCredits(): Optional = + sharedPoolCredits.getOptional("shared_pool_credits") + + /** + * Returns the raw JSON value of [allocatedCredits]. + * + * Unlike [allocatedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocated_credits") + @ExcludeMissing + fun _allocatedCredits(): JsonField = allocatedCredits + + /** + * Returns the raw JSON value of [consumedCredits]. + * + * Unlike [consumedCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("consumed_credits") + @ExcludeMissing + fun _consumedCredits(): JsonField = consumedCredits + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [pricingUnit]. + * + * Unlike [pricingUnit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pricing_unit") + @ExcludeMissing + fun _pricingUnit(): JsonField = pricingUnit + + /** + * Returns the raw JSON value of [remainingCredits]. + * + * Unlike [remainingCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remaining_credits") + @ExcludeMissing + fun _remainingCredits(): JsonField = remainingCredits + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Returns the raw JSON value of [subscriptionId]. + * + * Unlike [subscriptionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("subscription_id") + @ExcludeMissing + fun _subscriptionId(): JsonField = subscriptionId + + /** + * Returns the raw JSON value of [allocationEligibleCredits]. + * + * Unlike [allocationEligibleCredits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allocation_eligible_credits") + @ExcludeMissing + fun _allocationEligibleCredits(): JsonField = allocationEligibleCredits + + /** + * Returns the raw JSON value of [externalLicenseId]. + * + * Unlike [externalLicenseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_license_id") + @ExcludeMissing + fun _externalLicenseId(): JsonField = externalLicenseId + + /** + * Returns the raw JSON value of [licenseId]. + * + * Unlike [licenseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_id") @ExcludeMissing fun _licenseId(): JsonField = licenseId + + /** + * Returns the raw JSON value of [sharedPoolCredits]. + * + * Unlike [sharedPoolCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_pool_credits") + @ExcludeMissing + fun _sharedPoolCredits(): JsonField = sharedPoolCredits + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var allocatedCredits: JsonField? = null + private var consumedCredits: JsonField? = null + private var endDate: JsonField? = null + private var licenseTypeId: JsonField? = null + private var pricingUnit: JsonField? = null + private var remainingCredits: JsonField? = null + private var startDate: JsonField? = null + private var subscriptionId: JsonField? = null + private var allocationEligibleCredits: JsonField = JsonMissing.of() + private var externalLicenseId: JsonField = JsonMissing.of() + private var licenseId: JsonField = JsonMissing.of() + private var sharedPoolCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + allocatedCredits = data.allocatedCredits + consumedCredits = data.consumedCredits + endDate = data.endDate + licenseTypeId = data.licenseTypeId + pricingUnit = data.pricingUnit + remainingCredits = data.remainingCredits + startDate = data.startDate + subscriptionId = data.subscriptionId + allocationEligibleCredits = data.allocationEligibleCredits + externalLicenseId = data.externalLicenseId + licenseId = data.licenseId + sharedPoolCredits = data.sharedPoolCredits + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The total credits allocated to this license for the period. */ + fun allocatedCredits(allocatedCredits: Double) = + allocatedCredits(JsonField.of(allocatedCredits)) + + /** + * Sets [Builder.allocatedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocatedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allocatedCredits(allocatedCredits: JsonField) = apply { + this.allocatedCredits = allocatedCredits + } + + /** The credits consumed by this license for the period. */ + fun consumedCredits(consumedCredits: Double) = + consumedCredits(JsonField.of(consumedCredits)) + + /** + * Sets [Builder.consumedCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.consumedCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumedCredits(consumedCredits: JsonField) = apply { + this.consumedCredits = consumedCredits + } + + /** The end date of the usage period. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The unique identifier for the license type. */ + fun licenseTypeId(licenseTypeId: String) = licenseTypeId(JsonField.of(licenseTypeId)) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** The pricing unit for the credits (e.g., 'credits'). */ + fun pricingUnit(pricingUnit: String) = pricingUnit(JsonField.of(pricingUnit)) + + /** + * Sets [Builder.pricingUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pricingUnit(pricingUnit: JsonField) = apply { + this.pricingUnit = pricingUnit + } + + /** The remaining credits available for this license (allocated - consumed). */ + fun remainingCredits(remainingCredits: Double) = + remainingCredits(JsonField.of(remainingCredits)) + + /** + * Sets [Builder.remainingCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.remainingCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remainingCredits(remainingCredits: JsonField) = apply { + this.remainingCredits = remainingCredits + } + + /** The start date of the usage period. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The unique identifier for the subscription. */ + fun subscriptionId(subscriptionId: String) = + subscriptionId(JsonField.of(subscriptionId)) + + /** + * Sets [Builder.subscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subscriptionId(subscriptionId: JsonField) = apply { + this.subscriptionId = subscriptionId + } + + /** + * Credits consumed while the license was active (eligible for individual allocation + * deduction). + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double?) = + allocationEligibleCredits(JsonField.ofNullable(allocationEligibleCredits)) + + /** + * Alias for [Builder.allocationEligibleCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Double) = + allocationEligibleCredits(allocationEligibleCredits as Double?) + + /** + * Alias for calling [Builder.allocationEligibleCredits] with + * `allocationEligibleCredits.orElse(null)`. + */ + fun allocationEligibleCredits(allocationEligibleCredits: Optional) = + allocationEligibleCredits(allocationEligibleCredits.getOrNull()) + + /** + * Sets [Builder.allocationEligibleCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationEligibleCredits] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allocationEligibleCredits(allocationEligibleCredits: JsonField) = apply { + this.allocationEligibleCredits = allocationEligibleCredits + } + + /** The external identifier for the license. Null when grouped by day only. */ + fun externalLicenseId(externalLicenseId: String?) = + externalLicenseId(JsonField.ofNullable(externalLicenseId)) + + /** + * Alias for calling [Builder.externalLicenseId] with `externalLicenseId.orElse(null)`. + */ + fun externalLicenseId(externalLicenseId: Optional) = + externalLicenseId(externalLicenseId.getOrNull()) + + /** + * Sets [Builder.externalLicenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalLicenseId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalLicenseId(externalLicenseId: JsonField) = apply { + this.externalLicenseId = externalLicenseId + } + + /** The unique identifier for the license. Null when grouped by day only. */ + fun licenseId(licenseId: String?) = licenseId(JsonField.ofNullable(licenseId)) + + /** Alias for calling [Builder.licenseId] with `licenseId.orElse(null)`. */ + fun licenseId(licenseId: Optional) = licenseId(licenseId.getOrNull()) + + /** + * Sets [Builder.licenseId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseId(licenseId: JsonField) = apply { this.licenseId = licenseId } + + /** + * Credits consumed while the license was inactive (draws from shared pool, not + * individual allocation). + */ + fun sharedPoolCredits(sharedPoolCredits: Double?) = + sharedPoolCredits(JsonField.ofNullable(sharedPoolCredits)) + + /** + * Alias for [Builder.sharedPoolCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun sharedPoolCredits(sharedPoolCredits: Double) = + sharedPoolCredits(sharedPoolCredits as Double?) + + /** + * Alias for calling [Builder.sharedPoolCredits] with `sharedPoolCredits.orElse(null)`. + */ + fun sharedPoolCredits(sharedPoolCredits: Optional) = + sharedPoolCredits(sharedPoolCredits.getOrNull()) + + /** + * Sets [Builder.sharedPoolCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedPoolCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedPoolCredits(sharedPoolCredits: JsonField) = apply { + this.sharedPoolCredits = sharedPoolCredits + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocatedCredits() + * .consumedCredits() + * .endDate() + * .licenseTypeId() + * .pricingUnit() + * .remainingCredits() + * .startDate() + * .subscriptionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("allocatedCredits", allocatedCredits), + checkRequired("consumedCredits", consumedCredits), + checkRequired("endDate", endDate), + checkRequired("licenseTypeId", licenseTypeId), + checkRequired("pricingUnit", pricingUnit), + checkRequired("remainingCredits", remainingCredits), + checkRequired("startDate", startDate), + checkRequired("subscriptionId", subscriptionId), + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Data = apply { + if (validated) { + return@apply + } + + allocatedCredits() + consumedCredits() + endDate() + licenseTypeId() + pricingUnit() + remainingCredits() + startDate() + subscriptionId() + allocationEligibleCredits() + externalLicenseId() + licenseId() + sharedPoolCredits() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allocatedCredits.asKnown().isPresent) 1 else 0) + + (if (consumedCredits.asKnown().isPresent) 1 else 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (if (pricingUnit.asKnown().isPresent) 1 else 0) + + (if (remainingCredits.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (subscriptionId.asKnown().isPresent) 1 else 0) + + (if (allocationEligibleCredits.asKnown().isPresent) 1 else 0) + + (if (externalLicenseId.asKnown().isPresent) 1 else 0) + + (if (licenseId.asKnown().isPresent) 1 else 0) + + (if (sharedPoolCredits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + allocatedCredits == other.allocatedCredits && + consumedCredits == other.consumedCredits && + endDate == other.endDate && + licenseTypeId == other.licenseTypeId && + pricingUnit == other.pricingUnit && + remainingCredits == other.remainingCredits && + startDate == other.startDate && + subscriptionId == other.subscriptionId && + allocationEligibleCredits == other.allocationEligibleCredits && + externalLicenseId == other.externalLicenseId && + licenseId == other.licenseId && + sharedPoolCredits == other.sharedPoolCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocatedCredits, + consumedCredits, + endDate, + licenseTypeId, + pricingUnit, + remainingCredits, + startDate, + subscriptionId, + allocationEligibleCredits, + externalLicenseId, + licenseId, + sharedPoolCredits, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{allocatedCredits=$allocatedCredits, consumedCredits=$consumedCredits, endDate=$endDate, licenseTypeId=$licenseTypeId, pricingUnit=$pricingUnit, remainingCredits=$remainingCredits, startDate=$startDate, subscriptionId=$subscriptionId, allocationEligibleCredits=$allocationEligibleCredits, externalLicenseId=$externalLicenseId, licenseId=$licenseId, sharedPoolCredits=$sharedPoolCredits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseUsageGetUsageResponse && + data == other.data && + paginationMetadata == other.paginationMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, paginationMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseUsageGetUsageResponse{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt index 424c1b784..c187f89b7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfig.kt @@ -247,6 +247,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MatrixConfig = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt index 8f496f4f7..e86e0a7c9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixSubLineItem.kt @@ -349,6 +349,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MatrixSubLineItem = apply { if (validated) { return@apply @@ -467,6 +475,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt index d9924e4bc..0a4aeb866 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValue.kt @@ -190,6 +190,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MatrixValue = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt index 1e2916025..cad1c3296 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfig.kt @@ -283,6 +283,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MatrixWithAllocationConfig = apply { if (validated) { return@apply @@ -496,6 +504,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixValue = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Maximum.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Maximum.kt index 55b360d58..0aadada35 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Maximum.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Maximum.kt @@ -254,6 +254,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Maximum = apply { if (validated) { return@apply @@ -486,6 +494,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -625,6 +642,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -754,6 +781,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt index 6b7c24d50..21b16781f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumInterval.kt @@ -332,6 +332,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MaximumInterval = apply { if (validated) { return@apply @@ -568,6 +576,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -707,6 +724,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -836,6 +863,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt index f1ce80bf2..909d14894 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt @@ -647,6 +647,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -769,6 +778,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply 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 455b267e7..7471cde3b 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 @@ -10,8 +10,8 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about the - * metrics including its name, description, and item. + * 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 item. */ class MetricFetchParams private constructor( diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt index 61126ef4f..b2c262a24 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageResponse.kt @@ -187,6 +187,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MetricListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt index 1b8badeeb..704cf3bad 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt @@ -12,8 +12,8 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * 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 item. + * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about the + * metrics including its name, description, and item. */ class MetricListParams private constructor( 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 7f158347e..24f1be56d 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 @@ -370,6 +370,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -477,6 +486,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Minimum.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Minimum.kt index 58d74237a..53b5faeeb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Minimum.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Minimum.kt @@ -254,6 +254,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Minimum = apply { if (validated) { return@apply @@ -486,6 +494,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -625,6 +642,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -754,6 +781,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt index 527880a5e..34a2335a4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumInterval.kt @@ -332,6 +332,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MinimumInterval = apply { if (validated) { return@apply @@ -568,6 +576,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -707,6 +724,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -836,6 +863,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt index a62176d64..88a83d92a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryAmountDiscountAdjustment.kt @@ -505,6 +505,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MonetaryAmountDiscountAdjustment = apply { if (validated) { return@apply @@ -631,6 +639,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -871,6 +888,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1010,6 +1036,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1139,6 +1175,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt index 5ac307539..4c34adf60 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMaximumAdjustment.kt @@ -502,6 +502,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MonetaryMaximumAdjustment = apply { if (validated) { return@apply @@ -628,6 +636,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -868,6 +885,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1007,6 +1033,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1136,6 +1172,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt index 16b13835d..cf8ea7cf9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryMinimumAdjustment.kt @@ -536,6 +536,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MonetaryMinimumAdjustment = apply { if (validated) { return@apply @@ -664,6 +672,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -904,6 +921,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1043,6 +1069,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1172,6 +1208,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt index 81d7ecd6f..4ec3b4778 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryPercentageDiscountAdjustment.kt @@ -508,6 +508,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MonetaryPercentageDiscountAdjustment = apply { if (validated) { return@apply @@ -634,6 +642,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -874,6 +891,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1013,6 +1039,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1142,6 +1178,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt index f62766ab0..af65186b8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MonetaryUsageDiscountAdjustment.kt @@ -505,6 +505,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MonetaryUsageDiscountAdjustment = apply { if (validated) { return@apply @@ -631,6 +639,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -871,6 +888,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1010,6 +1036,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1139,6 +1175,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt index c89ec7541..36357abe3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscription.kt @@ -1519,6 +1519,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): MutatedSubscription = apply { if (validated) { return@apply @@ -1629,6 +1637,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = discountInterval.accept(new DiscountInterval.Visitor>() { + * @Override + * public Optional visitAmount(AmountDiscountInterval amount) { + * return Optional.of(amount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { amount != null -> visitor.visitAmount(amount) @@ -1639,6 +1676,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountInterval = apply { if (validated) { return@apply @@ -1862,6 +1908,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1995,6 +2050,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt index 7f851e297..69bf1831a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfiguration.kt @@ -189,6 +189,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewAccountingSyncConfiguration = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt index f2b06e1c5..464983973 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPrice.kt @@ -30,6 +30,8 @@ private constructor( private val expiresAtEndOfCadence: JsonField, private val filters: JsonField>, private val itemId: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, private val perUnitCostBasis: JsonField, private val additionalProperties: MutableMap, ) { @@ -49,6 +51,10 @@ private constructor( @ExcludeMissing filters: JsonField> = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("per_unit_cost_basis") @ExcludeMissing perUnitCostBasis: JsonField = JsonMissing.of(), @@ -60,6 +66,8 @@ private constructor( expiresAtEndOfCadence, filters, itemId, + licenseTypeId, + metadata, perUnitCostBasis, mutableMapOf(), ) @@ -125,6 +133,24 @@ private constructor( */ fun itemId(): Optional = itemId.getOptional("item_id") + /** + * The license type ID to associate the price with license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + /** * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced * according to the quantity and per unit cost basis specified for the allocation each cadence. @@ -189,6 +215,22 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [perUnitCostBasis]. * @@ -236,6 +278,8 @@ private constructor( private var expiresAtEndOfCadence: JsonField = JsonMissing.of() private var filters: JsonField>? = null private var itemId: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var perUnitCostBasis: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -248,6 +292,8 @@ private constructor( expiresAtEndOfCadence = newAllocationPrice.expiresAtEndOfCadence filters = newAllocationPrice.filters.map { it.toMutableList() } itemId = newAllocationPrice.itemId + licenseTypeId = newAllocationPrice.licenseTypeId + metadata = newAllocationPrice.metadata perUnitCostBasis = newAllocationPrice.perUnitCostBasis additionalProperties = newAllocationPrice.additionalProperties.toMutableMap() } @@ -387,6 +433,44 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** The license type ID to associate the price with license allocation. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * The (per-unit) cost basis of each created block. If non-zero, a customer will be invoiced * according to the quantity and per unit cost basis specified for the allocation each @@ -448,6 +532,8 @@ private constructor( expiresAtEndOfCadence, (filters ?: JsonMissing.of()).map { it.toImmutable() }, itemId, + licenseTypeId, + metadata, perUnitCostBasis, additionalProperties.toMutableMap(), ) @@ -455,6 +541,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewAllocationPrice = apply { if (validated) { return@apply @@ -467,6 +561,8 @@ private constructor( expiresAtEndOfCadence() filters().ifPresent { it.forEach { it.validate() } } itemId() + licenseTypeId() + metadata().ifPresent { it.validate() } perUnitCostBasis() validated = true } @@ -493,6 +589,8 @@ private constructor( (if (expiresAtEndOfCadence.asKnown().isPresent) 1 else 0) + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) /** The cadence at which to allocate the amount to the customer. */ @@ -600,6 +698,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -841,6 +948,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -956,6 +1072,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1085,6 +1211,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -1145,6 +1281,119 @@ private constructor( "Filter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1158,6 +1407,8 @@ private constructor( expiresAtEndOfCadence == other.expiresAtEndOfCadence && filters == other.filters && itemId == other.itemId && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties } @@ -1171,6 +1422,8 @@ private constructor( expiresAtEndOfCadence, filters, itemId, + licenseTypeId, + metadata, perUnitCostBasis, additionalProperties, ) @@ -1179,5 +1432,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, filters=$filters, itemId=$itemId, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + "NewAllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, customExpiration=$customExpiration, expiresAtEndOfCadence=$expiresAtEndOfCadence, filters=$filters, itemId=$itemId, licenseTypeId=$licenseTypeId, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt index 3ce9b5749..aff663a5a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAmountDiscount.kt @@ -509,6 +509,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewAmountDiscount = apply { if (validated) { return@apply @@ -635,6 +643,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -754,6 +771,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AppliesToAll = apply { if (validated) { return@apply @@ -994,6 +1020,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1133,6 +1168,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1262,6 +1307,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -1429,6 +1484,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt index e6d3152db..578222d81 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAvalaraTaxConfiguration.kt @@ -270,6 +270,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewAvalaraTaxConfiguration = apply { if (validated) { return@apply @@ -385,6 +393,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TaxProvider = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt index 44213f2b6..efe474c99 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfiguration.kt @@ -172,6 +172,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewBillingCycleConfiguration = apply { if (validated) { return@apply @@ -290,6 +298,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DurationUnit = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt index d0716c576..0bcf4b44b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewDimensionalPriceConfiguration.kt @@ -261,6 +261,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewDimensionalPriceConfiguration = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt index 1aaa47b7c..6fef0819b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( bulkConfig, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingBulkPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingBulkPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingBulkPrice.licenseTypeId metadata = newFloatingBulkPrice.metadata additionalProperties = newFloatingBulkPrice.additionalProperties.toMutableMap() } @@ -832,6 +856,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -905,6 +948,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -912,6 +956,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingBulkPrice = apply { if (validated) { return@apply @@ -933,6 +985,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -968,6 +1021,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1081,6 +1135,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1202,6 +1265,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1303,6 +1375,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1366,6 +1447,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1388,6 +1470,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1396,5 +1479,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt index 2f1da6385..4f67c5993 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( bulkWithProrationConfig, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -485,6 +508,7 @@ private constructor( invoiceGroupingKey = newFloatingBulkWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingBulkWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingBulkWithProrationPrice.licenseTypeId metadata = newFloatingBulkWithProrationPrice.metadata additionalProperties = newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() @@ -845,6 +869,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -918,6 +961,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -925,6 +969,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingBulkWithProrationPrice = apply { if (validated) { return@apply @@ -946,6 +998,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -981,6 +1034,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_proration pricing */ @@ -1114,6 +1168,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BulkWithProrationConfig = apply { if (validated) { return@apply @@ -1315,6 +1378,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1494,6 +1567,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1615,6 +1697,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1716,6 +1807,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1779,6 +1879,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1801,6 +1902,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1809,5 +1911,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt index 403783eed..83824682f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingCumulativeGroupedBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingCumulativeGroupedBulkPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingCumulativeGroupedBulkPrice.licenseTypeId metadata = newFloatingCumulativeGroupedBulkPrice.metadata additionalProperties = newFloatingCumulativeGroupedBulkPrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -927,6 +971,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingCumulativeGroupedBulkPrice = apply { if (validated) { return@apply @@ -948,6 +1000,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1036,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1096,6 +1150,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1306,6 +1369,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CumulativeGroupedBulkConfig = apply { if (validated) { return@apply @@ -1548,6 +1620,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DimensionValue = apply { if (validated) { return@apply @@ -1705,6 +1787,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1806,6 +1897,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1869,6 +1969,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1891,6 +1992,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1899,5 +2001,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt index a508400bb..faeceb843 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -399,6 +412,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -484,6 +507,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedAllocationPrice.licenseTypeId metadata = newFloatingGroupedAllocationPrice.metadata additionalProperties = newFloatingGroupedAllocationPrice.additionalProperties.toMutableMap() @@ -844,6 +868,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -917,6 +960,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -924,6 +968,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingGroupedAllocationPrice = apply { if (validated) { return@apply @@ -945,6 +997,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -980,6 +1033,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1093,6 +1147,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1334,6 +1397,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedAllocationConfig = apply { if (validated) { return@apply @@ -1470,6 +1542,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1571,6 +1652,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1634,6 +1724,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1656,6 +1747,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1664,5 +1756,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt index e1cd91b42..b2bc64fd8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedTieredPackagePrice.licenseTypeId metadata = newFloatingGroupedTieredPackagePrice.metadata additionalProperties = newFloatingGroupedTieredPackagePrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -927,6 +971,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingGroupedTieredPackagePrice = apply { if (validated) { return@apply @@ -948,6 +1000,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1036,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1096,6 +1150,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1348,6 +1411,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedTieredPackageConfig = apply { if (validated) { return@apply @@ -1542,6 +1614,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1697,6 +1779,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1798,6 +1889,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1861,6 +1961,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1883,6 +1984,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1891,5 +1993,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt index c9dc4809a..c62d4d91e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -482,6 +505,7 @@ private constructor( fixedPriceQuantity = newFloatingGroupedTieredPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingGroupedTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedTieredPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedTieredPrice.licenseTypeId metadata = newFloatingGroupedTieredPrice.metadata additionalProperties = newFloatingGroupedTieredPrice.additionalProperties.toMutableMap() } @@ -840,6 +864,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -913,6 +956,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -920,6 +964,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingGroupedTieredPrice = apply { if (validated) { return@apply @@ -941,6 +993,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -976,6 +1029,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1089,6 +1143,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1300,6 +1363,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedTieredConfig = apply { if (validated) { return@apply @@ -1497,6 +1569,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1649,6 +1731,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1750,6 +1841,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1813,6 +1913,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1835,6 +1936,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1843,5 +1945,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt index c674d7b0b..301e941dc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -402,6 +415,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -463,6 +485,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -490,6 +513,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedWithMeteredMinimumPrice.licenseTypeId metadata = newFloatingGroupedWithMeteredMinimumPrice.metadata additionalProperties = newFloatingGroupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() @@ -850,6 +874,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -923,6 +966,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -930,6 +974,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingGroupedWithMeteredMinimumPrice = apply { if (validated) { return@apply @@ -951,6 +1003,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -986,6 +1039,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1099,6 +1153,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1503,6 +1566,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedWithMeteredMinimumConfig = apply { if (validated) { return@apply @@ -1705,6 +1777,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScalingFactor = apply { if (validated) { return@apply @@ -1922,6 +2004,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitAmount = apply { if (validated) { return@apply @@ -2088,6 +2180,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -2189,6 +2290,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2252,6 +2362,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -2274,6 +2385,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -2282,5 +2394,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt index d22b0af45..9306cc524 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -462,6 +484,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -489,6 +512,7 @@ private constructor( invoiceGroupingKey = newFloatingGroupedWithProratedMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingGroupedWithProratedMinimumPrice.licenseTypeId metadata = newFloatingGroupedWithProratedMinimumPrice.metadata additionalProperties = newFloatingGroupedWithProratedMinimumPrice.additionalProperties.toMutableMap() @@ -849,6 +873,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -922,6 +965,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -929,6 +973,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingGroupedWithProratedMinimumPrice = apply { if (validated) { return@apply @@ -950,6 +1002,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -985,6 +1038,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1098,6 +1152,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1332,6 +1395,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedWithProratedMinimumConfig = apply { if (validated) { return@apply @@ -1468,6 +1540,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1569,6 +1650,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1632,6 +1722,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1654,6 +1745,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1662,5 +1754,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt index f0792977e..a51694e61 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingMatrixPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingMatrixPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMatrixPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMatrixPrice.licenseTypeId metadata = newFloatingMatrixPrice.metadata additionalProperties = newFloatingMatrixPrice.additionalProperties.toMutableMap() } @@ -834,6 +858,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -907,6 +950,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -914,6 +958,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingMatrixPrice = apply { if (validated) { return@apply @@ -935,6 +987,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -970,6 +1023,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1083,6 +1137,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1204,6 +1267,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1305,6 +1377,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1368,6 +1449,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1390,6 +1472,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1398,5 +1481,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt index 0038970cc..665b93a58 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -487,6 +510,7 @@ private constructor( invoiceGroupingKey = newFloatingMatrixWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMatrixWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMatrixWithAllocationPrice.licenseTypeId metadata = newFloatingMatrixWithAllocationPrice.metadata additionalProperties = newFloatingMatrixWithAllocationPrice.additionalProperties.toMutableMap() @@ -846,6 +870,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -919,6 +962,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -926,6 +970,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingMatrixWithAllocationPrice = apply { if (validated) { return@apply @@ -947,6 +999,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -982,6 +1035,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1095,6 +1149,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1216,6 +1279,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1317,6 +1389,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1380,6 +1461,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1402,6 +1484,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1410,5 +1493,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt index 027156aab..da26274ac 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMatrixWithDisplayNamePrice.licenseTypeId metadata = newFloatingMatrixWithDisplayNamePrice.metadata additionalProperties = newFloatingMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -927,6 +971,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingMatrixWithDisplayNamePrice = apply { if (validated) { return@apply @@ -948,6 +1000,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1036,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1096,6 +1150,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1307,6 +1370,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixWithDisplayNameConfig = apply { if (validated) { return@apply @@ -1549,6 +1621,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitAmount = apply { if (validated) { return@apply @@ -1706,6 +1788,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1807,6 +1898,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1870,6 +1970,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1892,6 +1993,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1900,5 +2002,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt index 3cfa1d538..a33f93651 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMaxGroupTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMaxGroupTieredPackagePrice.licenseTypeId metadata = newFloatingMaxGroupTieredPackagePrice.metadata additionalProperties = newFloatingMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -927,6 +971,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingMaxGroupTieredPackagePrice = apply { if (validated) { return@apply @@ -948,6 +1000,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1036,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1096,6 +1150,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1344,6 +1407,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MaxGroupTieredPackageConfig = apply { if (validated) { return@apply @@ -1543,6 +1615,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1698,6 +1780,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1799,6 +1890,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1862,6 +1962,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1884,6 +1985,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1892,5 +1994,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt index 4ed974d20..c06d3d696 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -399,6 +412,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -484,6 +507,7 @@ private constructor( invoiceGroupingKey = newFloatingMinimumCompositePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingMinimumCompositePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingMinimumCompositePrice.licenseTypeId metadata = newFloatingMinimumCompositePrice.metadata additionalProperties = newFloatingMinimumCompositePrice.additionalProperties.toMutableMap() @@ -844,6 +868,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -917,6 +960,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -924,6 +968,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingMinimumCompositePrice = apply { if (validated) { return@apply @@ -945,6 +997,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -980,6 +1033,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1093,6 +1147,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1289,6 +1352,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MinimumCompositeConfig = apply { if (validated) { return@apply @@ -1422,6 +1494,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1523,6 +1604,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1586,6 +1676,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1608,6 +1699,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1616,5 +1708,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMinimumCompositePrice{cadence=$cadence, currency=$currency, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingMinimumCompositePrice{cadence=$cadence, currency=$currency, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt index fb230bd52..e24aa0d46 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackagePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingPackagePrice.fixedPriceQuantity invoiceGroupingKey = newFloatingPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingPackagePrice.licenseTypeId metadata = newFloatingPackagePrice.metadata additionalProperties = newFloatingPackagePrice.additionalProperties.toMutableMap() } @@ -834,6 +858,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -907,6 +950,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -914,6 +958,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingPackagePrice = apply { if (validated) { return@apply @@ -935,6 +987,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -970,6 +1023,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1083,6 +1137,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1204,6 +1267,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1305,6 +1377,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1368,6 +1449,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1390,6 +1472,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1398,5 +1481,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt index f14ba65cf..243e354f4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -487,6 +510,7 @@ private constructor( invoiceGroupingKey = newFloatingPackageWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingPackageWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingPackageWithAllocationPrice.licenseTypeId metadata = newFloatingPackageWithAllocationPrice.metadata additionalProperties = newFloatingPackageWithAllocationPrice.additionalProperties.toMutableMap() @@ -846,6 +870,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -919,6 +962,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -926,6 +970,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingPackageWithAllocationPrice = apply { if (validated) { return@apply @@ -947,6 +999,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -982,6 +1035,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1095,6 +1149,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1216,6 +1279,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1449,6 +1521,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PackageWithAllocationConfig = apply { if (validated) { return@apply @@ -1565,6 +1646,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1628,6 +1718,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1650,6 +1741,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1658,5 +1750,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt index 3f49c742f..4e7c73d1a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPrice.kt @@ -40,6 +40,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -106,6 +110,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -405,6 +418,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -467,6 +489,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -497,6 +520,7 @@ private constructor( invoiceGroupingKey = newFloatingScalableMatrixWithTieredPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingScalableMatrixWithTieredPricingPrice.licenseTypeId metadata = newFloatingScalableMatrixWithTieredPricingPrice.metadata additionalProperties = newFloatingScalableMatrixWithTieredPricingPrice.additionalProperties.toMutableMap() @@ -862,6 +886,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -938,6 +981,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -945,6 +989,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingScalableMatrixWithTieredPricingPrice = apply { if (validated) { return@apply @@ -966,6 +1018,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -1001,6 +1054,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1114,6 +1168,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1236,6 +1299,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1553,6 +1625,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScalableMatrixWithTieredPricingConfig = apply { if (validated) { return@apply @@ -1798,6 +1879,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixScalingFactor = apply { if (validated) { return@apply @@ -2021,6 +2112,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -2163,6 +2264,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2226,6 +2336,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -2248,6 +2359,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -2256,5 +2368,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt index 288ff9601..02ef0cdeb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -402,6 +415,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -464,6 +486,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -493,6 +516,7 @@ private constructor( invoiceGroupingKey = newFloatingScalableMatrixWithUnitPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingScalableMatrixWithUnitPricingPrice.licenseTypeId metadata = newFloatingScalableMatrixWithUnitPricingPrice.metadata additionalProperties = newFloatingScalableMatrixWithUnitPricingPrice.additionalProperties.toMutableMap() @@ -853,6 +877,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -929,6 +972,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -936,6 +980,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingScalableMatrixWithUnitPricingPrice = apply { if (validated) { return@apply @@ -957,6 +1009,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -992,6 +1045,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1105,6 +1159,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1227,6 +1290,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1272,6 +1344,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -1288,6 +1361,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @JsonProperty("second_dimension") @ExcludeMissing @@ -1296,6 +1372,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -1326,6 +1403,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -1369,6 +1454,15 @@ private constructor( */ @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -1420,6 +1514,7 @@ private constructor( private var firstDimension: JsonField? = null private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1434,6 +1529,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -1495,6 +1591,23 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = groupingKey(JsonField.ofNullable(groupingKey)) + + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -1576,6 +1689,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -1584,6 +1698,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScalableMatrixWithUnitPricingConfig = apply { if (validated) { return@apply @@ -1592,6 +1715,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -1616,6 +1740,7 @@ private constructor( (if (firstDimension.asKnown().isPresent) 1 else 0) + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + (if (prorate.asKnown().isPresent) 1 else 0) + (if (secondDimension.asKnown().isPresent) 1 else 0) @@ -1831,6 +1956,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixScalingFactor = apply { if (validated) { return@apply @@ -1898,6 +2033,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -1908,6 +2044,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -1917,7 +2054,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** @@ -1983,6 +2120,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2046,6 +2192,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -2068,6 +2215,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -2076,5 +2224,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt index 5d4817829..9deacb1a8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingThresholdTotalAmountPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingThresholdTotalAmountPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingThresholdTotalAmountPrice.licenseTypeId metadata = newFloatingThresholdTotalAmountPrice.metadata additionalProperties = newFloatingThresholdTotalAmountPrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -927,6 +971,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingThresholdTotalAmountPrice = apply { if (validated) { return@apply @@ -948,6 +1000,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1036,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1096,6 +1150,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1217,6 +1280,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1442,6 +1514,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ThresholdTotalAmountConfig = apply { if (validated) { return@apply @@ -1636,6 +1717,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ConsumptionTable = apply { if (validated) { return@apply @@ -1770,6 +1861,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1833,6 +1933,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1855,6 +1956,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1863,5 +1965,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt index 2e0f9bb42..05f4a312b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -482,6 +505,7 @@ private constructor( fixedPriceQuantity = newFloatingTieredPackagePrice.fixedPriceQuantity invoiceGroupingKey = newFloatingTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredPackagePrice.licenseTypeId metadata = newFloatingTieredPackagePrice.metadata additionalProperties = newFloatingTieredPackagePrice.additionalProperties.toMutableMap() } @@ -840,6 +864,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -913,6 +956,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -920,6 +964,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingTieredPackagePrice = apply { if (validated) { return@apply @@ -941,6 +993,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -976,6 +1029,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1089,6 +1143,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1210,6 +1273,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1424,6 +1496,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackageConfig = apply { if (validated) { return@apply @@ -1616,6 +1697,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1748,6 +1839,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1811,6 +1911,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1833,6 +1934,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1841,5 +1943,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt index df8245039..d987b4587 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -105,6 +109,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -246,6 +251,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -402,6 +415,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -463,6 +485,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -490,6 +513,7 @@ private constructor( invoiceGroupingKey = newFloatingTieredPackageWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredPackageWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredPackageWithMinimumPrice.licenseTypeId metadata = newFloatingTieredPackageWithMinimumPrice.metadata additionalProperties = newFloatingTieredPackageWithMinimumPrice.additionalProperties.toMutableMap() @@ -850,6 +874,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -923,6 +966,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -930,6 +974,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingTieredPackageWithMinimumPrice = apply { if (validated) { return@apply @@ -951,6 +1003,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -986,6 +1039,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1099,6 +1153,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1220,6 +1283,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1433,6 +1505,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackageWithMinimumConfig = apply { if (validated) { return@apply @@ -1662,6 +1743,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1797,6 +1888,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1860,6 +1960,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1882,6 +1983,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1890,5 +1992,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt index 803a833a7..0d84ba0d6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingTieredPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredPrice.licenseTypeId metadata = newFloatingTieredPrice.metadata additionalProperties = newFloatingTieredPrice.additionalProperties.toMutableMap() } @@ -834,6 +858,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -907,6 +950,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -914,6 +958,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingTieredPrice = apply { if (validated) { return@apply @@ -935,6 +987,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -970,6 +1023,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1083,6 +1137,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1204,6 +1267,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1305,6 +1377,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1368,6 +1449,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1390,6 +1472,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1398,5 +1481,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt index c8f1fe5b4..35a80d9e1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -400,6 +413,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -460,6 +482,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -485,6 +508,7 @@ private constructor( invoiceGroupingKey = newFloatingTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredWithMinimumPrice.licenseTypeId metadata = newFloatingTieredWithMinimumPrice.metadata additionalProperties = newFloatingTieredWithMinimumPrice.additionalProperties.toMutableMap() @@ -845,6 +869,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -918,6 +961,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -925,6 +969,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingTieredWithMinimumPrice = apply { if (validated) { return@apply @@ -946,6 +998,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -981,6 +1034,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1094,6 +1148,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1215,6 +1278,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1461,6 +1533,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredWithMinimumConfig = apply { if (validated) { return@apply @@ -1700,6 +1781,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1838,6 +1929,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1901,6 +2001,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1923,6 +2024,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1931,5 +2033,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt index bb9ebf2a4..13e9e2ef0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -104,6 +108,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -245,6 +250,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -401,6 +414,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -461,6 +483,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -488,6 +511,7 @@ private constructor( invoiceGroupingKey = newFloatingTieredWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingTieredWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingTieredWithProrationPrice.licenseTypeId metadata = newFloatingTieredWithProrationPrice.metadata additionalProperties = newFloatingTieredWithProrationPrice.additionalProperties.toMutableMap() @@ -847,6 +871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -920,6 +963,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -927,6 +971,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingTieredWithProrationPrice = apply { if (validated) { return@apply @@ -948,6 +1000,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -983,6 +1036,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1096,6 +1150,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1217,6 +1280,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1390,6 +1462,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply @@ -1588,6 +1669,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1719,6 +1810,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1782,6 +1882,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1804,6 +1905,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1812,5 +1914,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt index 75607f1db..b916428c3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -243,6 +248,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -397,6 +410,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -456,6 +478,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -477,6 +500,7 @@ private constructor( fixedPriceQuantity = newFloatingUnitPrice.fixedPriceQuantity invoiceGroupingKey = newFloatingUnitPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingUnitPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingUnitPrice.licenseTypeId metadata = newFloatingUnitPrice.metadata additionalProperties = newFloatingUnitPrice.additionalProperties.toMutableMap() } @@ -832,6 +856,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -905,6 +948,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -912,6 +956,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingUnitPrice = apply { if (validated) { return@apply @@ -933,6 +985,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -968,6 +1021,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1081,6 +1135,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1202,6 +1265,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1303,6 +1375,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1366,6 +1447,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1388,6 +1470,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1396,5 +1479,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt index 4a85f81d1..e9bc0929c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -399,6 +412,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -484,6 +507,7 @@ private constructor( invoiceGroupingKey = newFloatingUnitWithPercentPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingUnitWithPercentPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingUnitWithPercentPrice.licenseTypeId metadata = newFloatingUnitWithPercentPrice.metadata additionalProperties = newFloatingUnitWithPercentPrice.additionalProperties.toMutableMap() @@ -843,6 +867,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -916,6 +959,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -923,6 +967,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingUnitWithPercentPrice = apply { if (validated) { return@apply @@ -944,6 +996,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -979,6 +1032,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1092,6 +1146,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1213,6 +1276,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1406,6 +1478,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitWithPercentConfig = apply { if (validated) { return@apply @@ -1519,6 +1600,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1582,6 +1672,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1604,6 +1695,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1612,5 +1704,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt index a46c6e1d9..d1f0e9712 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -85,6 +86,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, @@ -103,6 +107,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -244,6 +249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -399,6 +412,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -459,6 +481,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -484,6 +507,7 @@ private constructor( invoiceGroupingKey = newFloatingUnitWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newFloatingUnitWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newFloatingUnitWithProrationPrice.licenseTypeId metadata = newFloatingUnitWithProrationPrice.metadata additionalProperties = newFloatingUnitWithProrationPrice.additionalProperties.toMutableMap() @@ -844,6 +868,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -917,6 +960,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -924,6 +968,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewFloatingUnitWithProrationPrice = apply { if (validated) { return@apply @@ -945,6 +997,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -980,6 +1033,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -1093,6 +1147,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1214,6 +1277,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1373,6 +1445,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitWithProrationConfig = apply { if (validated) { return@apply @@ -1479,6 +1560,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1542,6 +1632,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -1564,6 +1655,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -1572,5 +1664,5 @@ 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, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt index b4f92a9d2..9437d258e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMaximum.kt @@ -509,6 +509,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewMaximum = apply { if (validated) { return@apply @@ -635,6 +643,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -754,6 +771,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AppliesToAll = apply { if (validated) { return@apply @@ -994,6 +1020,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1133,6 +1168,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1262,6 +1307,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -1429,6 +1484,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt index bc22c10cc..91dbafb12 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewMinimum.kt @@ -543,6 +543,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewMinimum = apply { if (validated) { return@apply @@ -671,6 +679,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -790,6 +807,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AppliesToAll = apply { if (validated) { return@apply @@ -1030,6 +1056,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1169,6 +1204,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1298,6 +1343,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -1465,6 +1520,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt index 52767cb5a..94c9206cc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPercentageDiscount.kt @@ -511,6 +511,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPercentageDiscount = apply { if (validated) { return@apply @@ -637,6 +645,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -756,6 +773,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AppliesToAll = apply { if (validated) { return@apply @@ -996,6 +1022,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1135,6 +1170,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1264,6 +1309,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -1431,6 +1486,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt index 8960972a1..b888136ff 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanBulkPrice.fixedPriceQuantity invoiceGroupingKey = newPlanBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanBulkPrice.invoicingCycleConfiguration + licenseTypeId = newPlanBulkPrice.licenseTypeId metadata = newPlanBulkPrice.metadata referenceId = newPlanBulkPrice.referenceId additionalProperties = newPlanBulkPrice.additionalProperties.toMutableMap() @@ -863,6 +887,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -953,6 +996,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -961,6 +1005,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanBulkPrice = apply { if (validated) { return@apply @@ -982,6 +1034,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1018,6 +1071,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1132,6 +1186,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1253,6 +1316,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1354,6 +1426,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1417,6 +1498,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1440,6 +1522,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1449,5 +1532,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt index bebc0f4b7..bb5c60a5f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( fixedPriceQuantity = newPlanBulkWithProrationPrice.fixedPriceQuantity invoiceGroupingKey = newPlanBulkWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanBulkWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanBulkWithProrationPrice.licenseTypeId metadata = newPlanBulkWithProrationPrice.metadata referenceId = newPlanBulkWithProrationPrice.referenceId additionalProperties = newPlanBulkWithProrationPrice.additionalProperties.toMutableMap() @@ -872,6 +896,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -962,6 +1005,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -970,6 +1014,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanBulkWithProrationPrice = apply { if (validated) { return@apply @@ -991,6 +1043,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1027,6 +1080,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1161,6 +1215,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BulkWithProrationConfig = apply { if (validated) { return@apply @@ -1362,6 +1425,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1541,6 +1614,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1662,6 +1744,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1763,6 +1854,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1826,6 +1926,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1849,6 +1950,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1858,5 +1960,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt index 2c6298670..1e3e05a5f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanCumulativeGroupedBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanCumulativeGroupedBulkPrice.invoicingCycleConfiguration + licenseTypeId = newPlanCumulativeGroupedBulkPrice.licenseTypeId metadata = newPlanCumulativeGroupedBulkPrice.metadata referenceId = newPlanCumulativeGroupedBulkPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -975,6 +1019,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanCumulativeGroupedBulkPrice = apply { if (validated) { return@apply @@ -996,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1146,6 +1200,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1356,6 +1419,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CumulativeGroupedBulkConfig = apply { if (validated) { return@apply @@ -1598,6 +1670,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DimensionValue = apply { if (validated) { return@apply @@ -1755,6 +1837,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1856,6 +1947,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1919,6 +2019,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1942,6 +2043,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1951,5 +2053,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt index 5038dd58b..5d838bedf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -505,6 +528,7 @@ private constructor( fixedPriceQuantity = newPlanGroupedAllocationPrice.fixedPriceQuantity invoiceGroupingKey = newPlanGroupedAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedAllocationPrice.licenseTypeId metadata = newPlanGroupedAllocationPrice.metadata referenceId = newPlanGroupedAllocationPrice.referenceId additionalProperties = newPlanGroupedAllocationPrice.additionalProperties.toMutableMap() @@ -871,6 +895,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -961,6 +1004,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -969,6 +1013,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanGroupedAllocationPrice = apply { if (validated) { return@apply @@ -990,6 +1042,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1026,6 +1079,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1140,6 +1194,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1381,6 +1444,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedAllocationConfig = apply { if (validated) { return@apply @@ -1517,6 +1589,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1618,6 +1699,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1681,6 +1771,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1704,6 +1795,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1713,5 +1805,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt index eff28004e..e4236b745 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanGroupedTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedTieredPackagePrice.licenseTypeId metadata = newPlanGroupedTieredPackagePrice.metadata referenceId = newPlanGroupedTieredPackagePrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -975,6 +1019,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanGroupedTieredPackagePrice = apply { if (validated) { return@apply @@ -996,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1146,6 +1200,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1398,6 +1461,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedTieredPackageConfig = apply { if (validated) { return@apply @@ -1592,6 +1664,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1747,6 +1829,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1848,6 +1939,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1911,6 +2011,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1934,6 +2035,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1943,5 +2045,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt index 908dc8d42..9c3f78790 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedTieredPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( fixedPriceQuantity = newPlanGroupedTieredPrice.fixedPriceQuantity invoiceGroupingKey = newPlanGroupedTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedTieredPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedTieredPrice.licenseTypeId metadata = newPlanGroupedTieredPrice.metadata referenceId = newPlanGroupedTieredPrice.referenceId additionalProperties = newPlanGroupedTieredPrice.additionalProperties.toMutableMap() @@ -869,6 +893,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -959,6 +1002,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -967,6 +1011,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanGroupedTieredPrice = apply { if (validated) { return@apply @@ -988,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1024,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1138,6 +1192,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1349,6 +1412,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedTieredConfig = apply { if (validated) { return@apply @@ -1546,6 +1618,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1698,6 +1780,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1799,6 +1890,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1862,6 +1962,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1885,6 +1986,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1894,5 +1996,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt index 0c06163b4..53f6279d5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -514,6 +537,7 @@ private constructor( invoiceGroupingKey = newPlanGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedWithMeteredMinimumPrice.licenseTypeId metadata = newPlanGroupedWithMeteredMinimumPrice.metadata referenceId = newPlanGroupedWithMeteredMinimumPrice.referenceId additionalProperties = @@ -881,6 +905,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -971,6 +1014,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -979,6 +1023,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanGroupedWithMeteredMinimumPrice = apply { if (validated) { return@apply @@ -1000,6 +1052,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1036,6 +1089,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1150,6 +1204,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1554,6 +1617,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedWithMeteredMinimumConfig = apply { if (validated) { return@apply @@ -1756,6 +1828,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScalingFactor = apply { if (validated) { return@apply @@ -1973,6 +2055,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitAmount = apply { if (validated) { return@apply @@ -2139,6 +2231,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -2240,6 +2341,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2303,6 +2413,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2326,6 +2437,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2335,5 +2447,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt index cc44542c7..ee4f2b2c9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -485,6 +507,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -513,6 +536,7 @@ private constructor( invoiceGroupingKey = newPlanGroupedWithProratedMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanGroupedWithProratedMinimumPrice.licenseTypeId metadata = newPlanGroupedWithProratedMinimumPrice.metadata referenceId = newPlanGroupedWithProratedMinimumPrice.referenceId additionalProperties = @@ -880,6 +904,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -970,6 +1013,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -978,6 +1022,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanGroupedWithProratedMinimumPrice = apply { if (validated) { return@apply @@ -999,6 +1051,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1035,6 +1088,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1149,6 +1203,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1383,6 +1446,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedWithProratedMinimumConfig = apply { if (validated) { return@apply @@ -1519,6 +1591,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1620,6 +1701,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1683,6 +1773,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1706,6 +1797,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1715,5 +1807,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt index 1fdfa4ccb..3253f911d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanMatrixPrice.fixedPriceQuantity invoiceGroupingKey = newPlanMatrixPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMatrixPrice.invoicingCycleConfiguration + licenseTypeId = newPlanMatrixPrice.licenseTypeId metadata = newPlanMatrixPrice.metadata referenceId = newPlanMatrixPrice.referenceId additionalProperties = newPlanMatrixPrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -963,6 +1007,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanMatrixPrice = apply { if (validated) { return@apply @@ -984,6 +1036,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1073,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1134,6 +1188,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1255,6 +1318,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1356,6 +1428,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1419,6 +1500,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1524,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1534,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt index c501222cb..40e6e8927 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newPlanMatrixWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMatrixWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanMatrixWithAllocationPrice.licenseTypeId metadata = newPlanMatrixWithAllocationPrice.metadata referenceId = newPlanMatrixWithAllocationPrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -974,6 +1018,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanMatrixWithAllocationPrice = apply { if (validated) { return@apply @@ -995,6 +1047,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1084,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1145,6 +1199,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1266,6 +1329,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1367,6 +1439,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1430,6 +1511,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1453,6 +1535,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1462,5 +1545,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt index 3d27388c6..cff0538dd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanMatrixWithDisplayNamePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMatrixWithDisplayNamePrice.invoicingCycleConfiguration + licenseTypeId = newPlanMatrixWithDisplayNamePrice.licenseTypeId metadata = newPlanMatrixWithDisplayNamePrice.metadata referenceId = newPlanMatrixWithDisplayNamePrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -975,6 +1019,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanMatrixWithDisplayNamePrice = apply { if (validated) { return@apply @@ -996,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1146,6 +1200,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1357,6 +1420,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixWithDisplayNameConfig = apply { if (validated) { return@apply @@ -1599,6 +1671,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitAmount = apply { if (validated) { return@apply @@ -1756,6 +1838,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1857,6 +1948,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1920,6 +2020,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1943,6 +2044,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1952,5 +2054,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt index d213396f0..2c26882c1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMaxGroupTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanMaxGroupTieredPackagePrice.licenseTypeId metadata = newPlanMaxGroupTieredPackagePrice.metadata referenceId = newPlanMaxGroupTieredPackagePrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -975,6 +1019,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanMaxGroupTieredPackagePrice = apply { if (validated) { return@apply @@ -996,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1146,6 +1200,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1394,6 +1457,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MaxGroupTieredPackageConfig = apply { if (validated) { return@apply @@ -1593,6 +1665,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1748,6 +1830,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1849,6 +1940,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1912,6 +2012,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1935,6 +2036,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1944,5 +2046,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt index 0ec463b42..2abc022b0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanMinimumCompositePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -481,6 +503,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( fixedPriceQuantity = newPlanMinimumCompositePrice.fixedPriceQuantity invoiceGroupingKey = newPlanMinimumCompositePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanMinimumCompositePrice.invoicingCycleConfiguration + licenseTypeId = newPlanMinimumCompositePrice.licenseTypeId metadata = newPlanMinimumCompositePrice.metadata referenceId = newPlanMinimumCompositePrice.referenceId additionalProperties = newPlanMinimumCompositePrice.additionalProperties.toMutableMap() @@ -870,6 +894,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -960,6 +1003,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -968,6 +1012,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanMinimumCompositePrice = apply { if (validated) { return@apply @@ -989,6 +1041,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1025,6 +1078,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1139,6 +1193,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1335,6 +1398,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MinimumCompositeConfig = apply { if (validated) { return@apply @@ -1468,6 +1540,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1569,6 +1650,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1632,6 +1722,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1655,6 +1746,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1664,5 +1756,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt index 2ba731b67..f9fce625f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackagePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanPackagePrice.fixedPriceQuantity invoiceGroupingKey = newPlanPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanPackagePrice.licenseTypeId metadata = newPlanPackagePrice.metadata referenceId = newPlanPackagePrice.referenceId additionalProperties = newPlanPackagePrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -963,6 +1007,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanPackagePrice = apply { if (validated) { return@apply @@ -984,6 +1036,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1073,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1134,6 +1188,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1255,6 +1318,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1356,6 +1428,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1419,6 +1500,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1524,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1534,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt index 432d40e9a..2ea09fc9b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newPlanPackageWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanPackageWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanPackageWithAllocationPrice.licenseTypeId metadata = newPlanPackageWithAllocationPrice.metadata referenceId = newPlanPackageWithAllocationPrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -974,6 +1018,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanPackageWithAllocationPrice = apply { if (validated) { return@apply @@ -995,6 +1047,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1084,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1145,6 +1199,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1266,6 +1329,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1499,6 +1571,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PackageWithAllocationConfig = apply { if (validated) { return@apply @@ -1615,6 +1696,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1678,6 +1768,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1701,6 +1792,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1710,5 +1802,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt index a2e27e4e8..588974e8d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPrice.kt @@ -40,6 +40,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -89,6 +90,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -110,6 +114,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -255,6 +260,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -420,6 +433,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -490,6 +512,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -518,6 +541,7 @@ private constructor( invoiceGroupingKey = newPlanScalableMatrixWithTieredPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + licenseTypeId = newPlanScalableMatrixWithTieredPricingPrice.licenseTypeId metadata = newPlanScalableMatrixWithTieredPricingPrice.metadata referenceId = newPlanScalableMatrixWithTieredPricingPrice.referenceId additionalProperties = @@ -890,6 +914,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -983,6 +1026,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -991,6 +1035,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanScalableMatrixWithTieredPricingPrice = apply { if (validated) { return@apply @@ -1012,6 +1064,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1048,6 +1101,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1162,6 +1216,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1284,6 +1347,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1601,6 +1673,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScalableMatrixWithTieredPricingConfig = apply { if (validated) { return@apply @@ -1846,6 +1927,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixScalingFactor = apply { if (validated) { return@apply @@ -2069,6 +2160,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -2211,6 +2312,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2274,6 +2384,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2297,6 +2408,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2306,5 +2418,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt index 13e0e76c5..6507cae30 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -487,6 +509,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -515,6 +538,7 @@ private constructor( invoiceGroupingKey = newPlanScalableMatrixWithUnitPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + licenseTypeId = newPlanScalableMatrixWithUnitPricingPrice.licenseTypeId metadata = newPlanScalableMatrixWithUnitPricingPrice.metadata referenceId = newPlanScalableMatrixWithUnitPricingPrice.referenceId additionalProperties = @@ -882,6 +906,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -975,6 +1018,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -983,6 +1027,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanScalableMatrixWithUnitPricingPrice = apply { if (validated) { return@apply @@ -1004,6 +1056,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1040,6 +1093,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1154,6 +1208,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1276,6 +1339,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1321,6 +1393,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -1337,6 +1410,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @JsonProperty("second_dimension") @ExcludeMissing @@ -1345,6 +1421,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -1375,6 +1452,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -1418,6 +1503,15 @@ private constructor( */ @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -1469,6 +1563,7 @@ private constructor( private var firstDimension: JsonField? = null private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1483,6 +1578,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -1544,6 +1640,23 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = groupingKey(JsonField.ofNullable(groupingKey)) + + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -1625,6 +1738,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -1633,6 +1747,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScalableMatrixWithUnitPricingConfig = apply { if (validated) { return@apply @@ -1641,6 +1764,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -1665,6 +1789,7 @@ private constructor( (if (firstDimension.asKnown().isPresent) 1 else 0) + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + (if (prorate.asKnown().isPresent) 1 else 0) + (if (secondDimension.asKnown().isPresent) 1 else 0) @@ -1880,6 +2005,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixScalingFactor = apply { if (validated) { return@apply @@ -1947,6 +2082,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -1957,6 +2093,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -1966,7 +2103,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** @@ -2032,6 +2169,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2095,6 +2241,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2118,6 +2265,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2127,5 +2275,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt index 77f2b25ac..307ab70ec 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newPlanThresholdTotalAmountPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanThresholdTotalAmountPrice.invoicingCycleConfiguration + licenseTypeId = newPlanThresholdTotalAmountPrice.licenseTypeId metadata = newPlanThresholdTotalAmountPrice.metadata referenceId = newPlanThresholdTotalAmountPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -975,6 +1019,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanThresholdTotalAmountPrice = apply { if (validated) { return@apply @@ -996,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1146,6 +1200,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1267,6 +1330,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1492,6 +1564,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ThresholdTotalAmountConfig = apply { if (validated) { return@apply @@ -1686,6 +1767,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ConsumptionTable = apply { if (validated) { return@apply @@ -1820,6 +1911,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1883,6 +1983,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1906,6 +2007,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1915,5 +2017,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt index 2b4b54067..3b6882645 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( fixedPriceQuantity = newPlanTieredPackagePrice.fixedPriceQuantity invoiceGroupingKey = newPlanTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredPackagePrice.licenseTypeId metadata = newPlanTieredPackagePrice.metadata referenceId = newPlanTieredPackagePrice.referenceId additionalProperties = newPlanTieredPackagePrice.additionalProperties.toMutableMap() @@ -869,6 +893,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -959,6 +1002,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -967,6 +1011,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanTieredPackagePrice = apply { if (validated) { return@apply @@ -988,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1024,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1138,6 +1192,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1259,6 +1322,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1473,6 +1545,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackageConfig = apply { if (validated) { return@apply @@ -1665,6 +1746,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1797,6 +1888,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1860,6 +1960,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1883,6 +1984,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1892,5 +1994,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt index bdc83bf3a..2cba1886a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -514,6 +537,7 @@ private constructor( invoiceGroupingKey = newPlanTieredPackageWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredPackageWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredPackageWithMinimumPrice.licenseTypeId metadata = newPlanTieredPackageWithMinimumPrice.metadata referenceId = newPlanTieredPackageWithMinimumPrice.referenceId additionalProperties = @@ -881,6 +905,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -971,6 +1014,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -979,6 +1023,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanTieredPackageWithMinimumPrice = apply { if (validated) { return@apply @@ -1000,6 +1052,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1036,6 +1089,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1150,6 +1204,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1271,6 +1334,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1484,6 +1556,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackageWithMinimumConfig = apply { if (validated) { return@apply @@ -1713,6 +1794,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1848,6 +1939,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1911,6 +2011,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1934,6 +2035,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1943,5 +2045,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt index 38bf989d4..c73c2d2fc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanTieredPrice.fixedPriceQuantity invoiceGroupingKey = newPlanTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredPrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredPrice.licenseTypeId metadata = newPlanTieredPrice.metadata referenceId = newPlanTieredPrice.referenceId additionalProperties = newPlanTieredPrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -963,6 +1007,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanTieredPrice = apply { if (validated) { return@apply @@ -984,6 +1036,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1073,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1134,6 +1188,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1255,6 +1318,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1356,6 +1428,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1419,6 +1500,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1524,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1534,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt index 299ef06bf..e48805d72 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -506,6 +529,7 @@ private constructor( fixedPriceQuantity = newPlanTieredWithMinimumPrice.fixedPriceQuantity invoiceGroupingKey = newPlanTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanTieredWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newPlanTieredWithMinimumPrice.licenseTypeId metadata = newPlanTieredWithMinimumPrice.metadata referenceId = newPlanTieredWithMinimumPrice.referenceId additionalProperties = newPlanTieredWithMinimumPrice.additionalProperties.toMutableMap() @@ -872,6 +896,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -962,6 +1005,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -970,6 +1014,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanTieredWithMinimumPrice = apply { if (validated) { return@apply @@ -991,6 +1043,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1027,6 +1080,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1141,6 +1195,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1262,6 +1325,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1508,6 +1580,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredWithMinimumConfig = apply { if (validated) { return@apply @@ -1747,6 +1828,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1885,6 +1976,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1948,6 +2048,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1971,6 +2072,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1980,5 +2082,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt index 5dcd3e753..b6472111a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newPlanUnitPrice.fixedPriceQuantity invoiceGroupingKey = newPlanUnitPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanUnitPrice.invoicingCycleConfiguration + licenseTypeId = newPlanUnitPrice.licenseTypeId metadata = newPlanUnitPrice.metadata referenceId = newPlanUnitPrice.referenceId additionalProperties = newPlanUnitPrice.additionalProperties.toMutableMap() @@ -863,6 +887,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -953,6 +996,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -961,6 +1005,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanUnitPrice = apply { if (validated) { return@apply @@ -982,6 +1034,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1018,6 +1071,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1132,6 +1186,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1253,6 +1316,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1354,6 +1426,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1417,6 +1498,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1440,6 +1522,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1449,5 +1532,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt index 2070811bc..ba107d7a3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -481,6 +503,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -504,6 +527,7 @@ private constructor( fixedPriceQuantity = newPlanUnitWithPercentPrice.fixedPriceQuantity invoiceGroupingKey = newPlanUnitWithPercentPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanUnitWithPercentPrice.invoicingCycleConfiguration + licenseTypeId = newPlanUnitWithPercentPrice.licenseTypeId metadata = newPlanUnitWithPercentPrice.metadata referenceId = newPlanUnitWithPercentPrice.referenceId additionalProperties = newPlanUnitWithPercentPrice.additionalProperties.toMutableMap() @@ -869,6 +893,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -959,6 +1002,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -967,6 +1011,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanUnitWithPercentPrice = apply { if (validated) { return@apply @@ -988,6 +1040,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1024,6 +1077,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1138,6 +1192,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1259,6 +1322,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1452,6 +1524,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitWithPercentConfig = apply { if (validated) { return@apply @@ -1565,6 +1646,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1628,6 +1718,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1651,6 +1742,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1660,5 +1752,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt index 47b377682..101ac4587 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -505,6 +528,7 @@ private constructor( fixedPriceQuantity = newPlanUnitWithProrationPrice.fixedPriceQuantity invoiceGroupingKey = newPlanUnitWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newPlanUnitWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newPlanUnitWithProrationPrice.licenseTypeId metadata = newPlanUnitWithProrationPrice.metadata referenceId = newPlanUnitWithProrationPrice.referenceId additionalProperties = newPlanUnitWithProrationPrice.additionalProperties.toMutableMap() @@ -871,6 +895,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -961,6 +1004,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -969,6 +1013,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewPlanUnitWithProrationPrice = apply { if (validated) { return@apply @@ -990,6 +1042,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1026,6 +1079,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1140,6 +1194,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1261,6 +1324,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1420,6 +1492,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitWithProrationConfig = apply { if (validated) { return@apply @@ -1526,6 +1607,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1589,6 +1679,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1612,6 +1703,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1621,5 +1713,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewPlanUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt index c34de26d2..622ddc5cb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfiguration.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewReportingConfiguration = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt index 550ff9d58..2b2d70a6f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSphereConfiguration.kt @@ -229,6 +229,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSphereConfiguration = apply { if (validated) { return@apply @@ -342,6 +350,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TaxProvider = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt index b10d26b6b..17f9ba519 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionBulkPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionBulkPrice.licenseTypeId metadata = newSubscriptionBulkPrice.metadata referenceId = newSubscriptionBulkPrice.referenceId additionalProperties = newSubscriptionBulkPrice.additionalProperties.toMutableMap() @@ -863,6 +887,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -953,6 +996,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -961,6 +1005,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionBulkPrice = apply { if (validated) { return@apply @@ -982,6 +1034,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1018,6 +1071,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1132,6 +1186,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1253,6 +1316,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1354,6 +1426,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1417,6 +1498,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1440,6 +1522,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1449,5 +1532,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt index 7ce89bc09..0e92fc5a5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newSubscriptionBulkWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionBulkWithProrationPrice.licenseTypeId metadata = newSubscriptionBulkWithProrationPrice.metadata referenceId = newSubscriptionBulkWithProrationPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -975,6 +1019,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionBulkWithProrationPrice = apply { if (validated) { return@apply @@ -996,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1166,6 +1220,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BulkWithProrationConfig = apply { if (validated) { return@apply @@ -1367,6 +1430,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1546,6 +1619,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1667,6 +1749,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1768,6 +1859,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1831,6 +1931,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1854,6 +1955,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1863,5 +1965,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt index 0714087d9..544fd1bff 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionCumulativeGroupedBulkPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionCumulativeGroupedBulkPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionCumulativeGroupedBulkPrice.licenseTypeId metadata = newSubscriptionCumulativeGroupedBulkPrice.metadata referenceId = newSubscriptionCumulativeGroupedBulkPrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -976,6 +1020,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionCumulativeGroupedBulkPrice = apply { if (validated) { return@apply @@ -997,6 +1049,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1086,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1147,6 +1201,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1357,6 +1420,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CumulativeGroupedBulkConfig = apply { if (validated) { return@apply @@ -1599,6 +1671,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DimensionValue = apply { if (validated) { return@apply @@ -1756,6 +1838,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1857,6 +1948,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1920,6 +2020,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1943,6 +2044,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1952,5 +2054,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt index 40d24c3aa..c532bd49f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedAllocationPrice.licenseTypeId metadata = newSubscriptionGroupedAllocationPrice.metadata referenceId = newSubscriptionGroupedAllocationPrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -974,6 +1018,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionGroupedAllocationPrice = apply { if (validated) { return@apply @@ -995,6 +1047,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1084,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1145,6 +1199,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1386,6 +1449,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedAllocationConfig = apply { if (validated) { return@apply @@ -1522,6 +1594,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1623,6 +1704,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1686,6 +1776,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1709,6 +1800,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1718,5 +1810,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt index f5474be24..32a696c03 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedTieredPackagePrice.licenseTypeId metadata = newSubscriptionGroupedTieredPackagePrice.metadata referenceId = newSubscriptionGroupedTieredPackagePrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -976,6 +1020,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionGroupedTieredPackagePrice = apply { if (validated) { return@apply @@ -997,6 +1049,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1086,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1147,6 +1201,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1399,6 +1462,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedTieredPackageConfig = apply { if (validated) { return@apply @@ -1593,6 +1665,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1748,6 +1830,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1849,6 +1940,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1912,6 +2012,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1935,6 +2036,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1944,5 +2046,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt index 69f5529b7..8d102dcbb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedTieredPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedTieredPrice.licenseTypeId metadata = newSubscriptionGroupedTieredPrice.metadata referenceId = newSubscriptionGroupedTieredPrice.referenceId additionalProperties = @@ -875,6 +899,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -965,6 +1008,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -973,6 +1017,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionGroupedTieredPrice = apply { if (validated) { return@apply @@ -994,6 +1046,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1030,6 +1083,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1144,6 +1198,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1355,6 +1418,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedTieredConfig = apply { if (validated) { return@apply @@ -1552,6 +1624,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1704,6 +1786,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1805,6 +1896,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1868,6 +1968,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1891,6 +1992,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1900,5 +2002,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedTieredPrice{cadence=$cadence, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt index 065e8f678..d3e18e5be 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -516,6 +539,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedWithMeteredMinimumPrice.licenseTypeId metadata = newSubscriptionGroupedWithMeteredMinimumPrice.metadata referenceId = newSubscriptionGroupedWithMeteredMinimumPrice.referenceId additionalProperties = @@ -883,6 +907,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -973,6 +1016,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -981,6 +1025,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionGroupedWithMeteredMinimumPrice = apply { if (validated) { return@apply @@ -1002,6 +1054,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1038,6 +1091,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1152,6 +1206,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1556,6 +1619,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedWithMeteredMinimumConfig = apply { if (validated) { return@apply @@ -1758,6 +1830,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScalingFactor = apply { if (validated) { return@apply @@ -1975,6 +2057,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitAmount = apply { if (validated) { return@apply @@ -2141,6 +2233,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -2242,6 +2343,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2305,6 +2415,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2328,6 +2439,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2337,5 +2449,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt index 477c3494b..82e5d522b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -485,6 +507,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -515,6 +538,7 @@ private constructor( invoiceGroupingKey = newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionGroupedWithProratedMinimumPrice.licenseTypeId metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId additionalProperties = @@ -882,6 +906,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -972,6 +1015,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -980,6 +1024,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { if (validated) { return@apply @@ -1001,6 +1053,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1037,6 +1090,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1151,6 +1205,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1385,6 +1448,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedWithProratedMinimumConfig = apply { if (validated) { return@apply @@ -1521,6 +1593,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1622,6 +1703,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1685,6 +1775,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1708,6 +1799,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1717,5 +1809,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt index eb63bedb1..3256e712f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMatrixPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMatrixPrice.licenseTypeId metadata = newSubscriptionMatrixPrice.metadata referenceId = newSubscriptionMatrixPrice.referenceId additionalProperties = newSubscriptionMatrixPrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -963,6 +1007,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionMatrixPrice = apply { if (validated) { return@apply @@ -984,6 +1036,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1073,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1134,6 +1188,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1255,6 +1318,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1356,6 +1428,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1419,6 +1500,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1524,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1534,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt index 1b57eceb5..8d22aab94 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMatrixWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMatrixWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMatrixWithAllocationPrice.licenseTypeId metadata = newSubscriptionMatrixWithAllocationPrice.metadata referenceId = newSubscriptionMatrixWithAllocationPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -975,6 +1019,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionMatrixWithAllocationPrice = apply { if (validated) { return@apply @@ -996,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1146,6 +1200,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1267,6 +1330,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1368,6 +1440,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1431,6 +1512,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1454,6 +1536,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1463,5 +1546,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMatrixWithAllocationPrice{cadence=$cadence, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt index 17fb78a46..1c18922a6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMatrixWithDisplayNamePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMatrixWithDisplayNamePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMatrixWithDisplayNamePrice.licenseTypeId metadata = newSubscriptionMatrixWithDisplayNamePrice.metadata referenceId = newSubscriptionMatrixWithDisplayNamePrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -976,6 +1020,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionMatrixWithDisplayNamePrice = apply { if (validated) { return@apply @@ -997,6 +1049,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1086,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1147,6 +1201,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1358,6 +1421,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixWithDisplayNameConfig = apply { if (validated) { return@apply @@ -1600,6 +1672,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitAmount = apply { if (validated) { return@apply @@ -1757,6 +1839,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1858,6 +1949,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1921,6 +2021,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1944,6 +2045,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1953,5 +2055,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt index cc8472998..0d1599186 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMaxGroupTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMaxGroupTieredPackagePrice.licenseTypeId metadata = newSubscriptionMaxGroupTieredPackagePrice.metadata referenceId = newSubscriptionMaxGroupTieredPackagePrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -976,6 +1020,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionMaxGroupTieredPackagePrice = apply { if (validated) { return@apply @@ -997,6 +1049,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1086,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1147,6 +1201,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1395,6 +1458,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MaxGroupTieredPackageConfig = apply { if (validated) { return@apply @@ -1594,6 +1666,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1749,6 +1831,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1850,6 +1941,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1913,6 +2013,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1936,6 +2037,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1945,5 +2047,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt index 0ea7c4a45..1a306fa09 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionMinimumCompositePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionMinimumCompositePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionMinimumCompositePrice.licenseTypeId metadata = newSubscriptionMinimumCompositePrice.metadata referenceId = newSubscriptionMinimumCompositePrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -974,6 +1018,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionMinimumCompositePrice = apply { if (validated) { return@apply @@ -995,6 +1047,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1084,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1145,6 +1199,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1341,6 +1404,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MinimumCompositeConfig = apply { if (validated) { return@apply @@ -1474,6 +1546,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1575,6 +1656,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1638,6 +1728,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1661,6 +1752,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1670,5 +1762,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionMinimumCompositePrice{cadence=$cadence, itemId=$itemId, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt index 421584a46..c4012e38d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackagePrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -502,6 +525,7 @@ private constructor( fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionPackagePrice.licenseTypeId metadata = newSubscriptionPackagePrice.metadata referenceId = newSubscriptionPackagePrice.referenceId additionalProperties = newSubscriptionPackagePrice.additionalProperties.toMutableMap() @@ -866,6 +890,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -956,6 +999,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -964,6 +1008,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionPackagePrice = apply { if (validated) { return@apply @@ -985,6 +1037,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1021,6 +1074,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1135,6 +1189,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1256,6 +1319,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1357,6 +1429,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1420,6 +1501,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1443,6 +1525,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1452,5 +1535,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt index a61347544..be3158d96 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -511,6 +534,7 @@ private constructor( invoiceGroupingKey = newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionPackageWithAllocationPrice.licenseTypeId metadata = newSubscriptionPackageWithAllocationPrice.metadata referenceId = newSubscriptionPackageWithAllocationPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -975,6 +1019,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { if (validated) { return@apply @@ -996,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1146,6 +1200,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1267,6 +1330,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1500,6 +1572,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PackageWithAllocationConfig = apply { if (validated) { return@apply @@ -1616,6 +1697,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1679,6 +1769,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1702,6 +1793,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1711,5 +1803,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt index e6c9a0281..430341ea2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPrice.kt @@ -40,6 +40,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -89,6 +90,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -110,6 +114,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -255,6 +260,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -420,6 +433,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -490,6 +512,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -523,6 +546,7 @@ private constructor( newSubscriptionScalableMatrixWithTieredPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionScalableMatrixWithTieredPricingPrice.licenseTypeId metadata = newSubscriptionScalableMatrixWithTieredPricingPrice.metadata referenceId = newSubscriptionScalableMatrixWithTieredPricingPrice.referenceId additionalProperties = @@ -896,6 +920,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -989,6 +1032,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -997,6 +1041,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionScalableMatrixWithTieredPricingPrice = apply { if (validated) { return@apply @@ -1018,6 +1070,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1054,6 +1107,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1168,6 +1222,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1290,6 +1353,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1607,6 +1679,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScalableMatrixWithTieredPricingConfig = apply { if (validated) { return@apply @@ -1852,6 +1933,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixScalingFactor = apply { if (validated) { return@apply @@ -2075,6 +2166,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -2217,6 +2318,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2280,6 +2390,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2303,6 +2414,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2312,5 +2424,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt index dc6e01f4f..a288eec66 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -487,6 +509,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -520,6 +543,7 @@ private constructor( newSubscriptionScalableMatrixWithUnitPricingPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionScalableMatrixWithUnitPricingPrice.licenseTypeId metadata = newSubscriptionScalableMatrixWithUnitPricingPrice.metadata referenceId = newSubscriptionScalableMatrixWithUnitPricingPrice.referenceId additionalProperties = @@ -888,6 +912,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -981,6 +1024,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -989,6 +1033,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionScalableMatrixWithUnitPricingPrice = apply { if (validated) { return@apply @@ -1010,6 +1062,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1046,6 +1099,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1160,6 +1214,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1282,6 +1345,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1327,6 +1399,7 @@ private constructor( private val firstDimension: JsonField, private val matrixScalingFactors: JsonField>, private val unitPrice: JsonField, + private val groupingKey: JsonField, private val prorate: JsonField, private val secondDimension: JsonField, private val additionalProperties: MutableMap, @@ -1343,6 +1416,9 @@ private constructor( @JsonProperty("unit_price") @ExcludeMissing unitPrice: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), @JsonProperty("prorate") @ExcludeMissing prorate: JsonField = JsonMissing.of(), @JsonProperty("second_dimension") @ExcludeMissing @@ -1351,6 +1427,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, mutableMapOf(), @@ -1381,6 +1458,14 @@ private constructor( */ fun unitPrice(): String = unitPrice.getRequired("unit_price") + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + /** * If true, the unit price will be prorated to the billing period * @@ -1424,6 +1509,15 @@ private constructor( */ @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + /** * Returns the raw JSON value of [prorate]. * @@ -1475,6 +1569,7 @@ private constructor( private var firstDimension: JsonField? = null private var matrixScalingFactors: JsonField>? = null private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() private var prorate: JsonField = JsonMissing.of() private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1489,6 +1584,7 @@ private constructor( it.toMutableList() } unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey prorate = scalableMatrixWithUnitPricingConfig.prorate secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = @@ -1550,6 +1646,23 @@ private constructor( */ fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = groupingKey(JsonField.ofNullable(groupingKey)) + + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + /** If true, the unit price will be prorated to the billing period */ fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) @@ -1631,6 +1744,7 @@ private constructor( it.toImmutable() }, checkRequired("unitPrice", unitPrice), + groupingKey, prorate, secondDimension, additionalProperties.toMutableMap(), @@ -1639,6 +1753,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ScalableMatrixWithUnitPricingConfig = apply { if (validated) { return@apply @@ -1647,6 +1770,7 @@ private constructor( firstDimension() matrixScalingFactors().forEach { it.validate() } unitPrice() + groupingKey() prorate() secondDimension() validated = true @@ -1671,6 +1795,7 @@ private constructor( (if (firstDimension.asKnown().isPresent) 1 else 0) + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + (if (prorate.asKnown().isPresent) 1 else 0) + (if (secondDimension.asKnown().isPresent) 1 else 0) @@ -1886,6 +2011,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixScalingFactor = apply { if (validated) { return@apply @@ -1953,6 +2088,7 @@ private constructor( firstDimension == other.firstDimension && matrixScalingFactors == other.matrixScalingFactors && unitPrice == other.unitPrice && + groupingKey == other.groupingKey && prorate == other.prorate && secondDimension == other.secondDimension && additionalProperties == other.additionalProperties @@ -1963,6 +2099,7 @@ private constructor( firstDimension, matrixScalingFactors, unitPrice, + groupingKey, prorate, secondDimension, additionalProperties, @@ -1972,7 +2109,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** @@ -2038,6 +2175,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2101,6 +2247,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -2124,6 +2271,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -2133,5 +2281,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt index e1b30a7fc..b163b3ee7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -416,6 +429,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -484,6 +506,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -512,6 +535,7 @@ private constructor( invoiceGroupingKey = newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionThresholdTotalAmountPrice.licenseTypeId metadata = newSubscriptionThresholdTotalAmountPrice.metadata referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId additionalProperties = @@ -878,6 +902,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -968,6 +1011,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -976,6 +1020,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { if (validated) { return@apply @@ -997,6 +1049,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1033,6 +1086,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1147,6 +1201,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1268,6 +1331,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1493,6 +1565,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ThresholdTotalAmountConfig = apply { if (validated) { return@apply @@ -1687,6 +1768,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ConsumptionTable = apply { if (validated) { return@apply @@ -1821,6 +1912,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1884,6 +1984,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1907,6 +2008,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1916,5 +2018,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt index 5c3968092..4cbc0eebb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredPackagePrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredPackagePrice.licenseTypeId metadata = newSubscriptionTieredPackagePrice.metadata referenceId = newSubscriptionTieredPackagePrice.referenceId additionalProperties = @@ -875,6 +899,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -965,6 +1008,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -973,6 +1017,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionTieredPackagePrice = apply { if (validated) { return@apply @@ -994,6 +1046,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1030,6 +1083,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1144,6 +1198,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1265,6 +1328,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1479,6 +1551,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackageConfig = apply { if (validated) { return@apply @@ -1671,6 +1752,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1803,6 +1894,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1866,6 +1966,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1889,6 +1990,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1898,5 +2000,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt index 9036a3f93..f7684b27c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -88,6 +89,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -109,6 +113,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -252,6 +257,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -417,6 +430,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -486,6 +508,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -515,6 +538,7 @@ private constructor( invoiceGroupingKey = newSubscriptionTieredPackageWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredPackageWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredPackageWithMinimumPrice.licenseTypeId metadata = newSubscriptionTieredPackageWithMinimumPrice.metadata referenceId = newSubscriptionTieredPackageWithMinimumPrice.referenceId additionalProperties = @@ -882,6 +906,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -972,6 +1015,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -980,6 +1024,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionTieredPackageWithMinimumPrice = apply { if (validated) { return@apply @@ -1001,6 +1053,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1037,6 +1090,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1151,6 +1205,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1272,6 +1335,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1485,6 +1557,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackageWithMinimumConfig = apply { if (validated) { return@apply @@ -1714,6 +1795,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1849,6 +1940,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1912,6 +2012,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1935,6 +2036,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1944,5 +2046,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredPackageWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt index 79610bbce..9582d63a5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredPrice.licenseTypeId metadata = newSubscriptionTieredPrice.metadata referenceId = newSubscriptionTieredPrice.referenceId additionalProperties = newSubscriptionTieredPrice.additionalProperties.toMutableMap() @@ -865,6 +889,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -955,6 +998,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -963,6 +1007,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionTieredPrice = apply { if (validated) { return@apply @@ -984,6 +1036,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1020,6 +1073,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1134,6 +1188,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1255,6 +1318,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1356,6 +1428,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1419,6 +1500,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1442,6 +1524,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1451,5 +1534,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt index ec6a48bdb..609595c78 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPrice.kt @@ -39,6 +39,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -87,6 +88,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -108,6 +112,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -251,6 +256,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -415,6 +428,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -483,6 +505,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -510,6 +533,7 @@ private constructor( invoiceGroupingKey = newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionTieredWithMinimumPrice.licenseTypeId metadata = newSubscriptionTieredWithMinimumPrice.metadata referenceId = newSubscriptionTieredWithMinimumPrice.referenceId additionalProperties = @@ -877,6 +901,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -967,6 +1010,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -975,6 +1019,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { if (validated) { return@apply @@ -996,6 +1048,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1032,6 +1085,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1146,6 +1200,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1267,6 +1330,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1513,6 +1585,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredWithMinimumConfig = apply { if (validated) { return@apply @@ -1752,6 +1833,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -1890,6 +1981,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1953,6 +2053,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1976,6 +2077,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1985,5 +2087,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt index 4d209d5f6..9108ba078 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -249,6 +254,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -412,6 +425,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -479,6 +501,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -501,6 +524,7 @@ private constructor( fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionUnitPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionUnitPrice.licenseTypeId metadata = newSubscriptionUnitPrice.metadata referenceId = newSubscriptionUnitPrice.referenceId additionalProperties = newSubscriptionUnitPrice.additionalProperties.toMutableMap() @@ -863,6 +887,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -953,6 +996,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -961,6 +1005,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionUnitPrice = apply { if (validated) { return@apply @@ -982,6 +1034,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1018,6 +1071,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1132,6 +1186,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1253,6 +1316,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1354,6 +1426,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1417,6 +1498,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1440,6 +1522,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1449,5 +1532,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt index fb86e9e26..4b9e954bf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionUnitWithPercentPrice.licenseTypeId metadata = newSubscriptionUnitWithPercentPrice.metadata referenceId = newSubscriptionUnitWithPercentPrice.referenceId additionalProperties = @@ -875,6 +899,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -965,6 +1008,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -973,6 +1017,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionUnitWithPercentPrice = apply { if (validated) { return@apply @@ -994,6 +1046,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1030,6 +1083,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1144,6 +1198,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1265,6 +1328,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1458,6 +1530,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitWithPercentConfig = apply { if (validated) { return@apply @@ -1571,6 +1652,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1634,6 +1724,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1657,6 +1748,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1666,5 +1758,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt index f41dd44b1..ff6219e6c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPrice.kt @@ -38,6 +38,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -86,6 +87,9 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("reference_id") @ExcludeMissing @@ -107,6 +111,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -250,6 +255,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to @@ -414,6 +427,15 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -482,6 +504,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -509,6 +532,7 @@ private constructor( invoiceGroupingKey = newSubscriptionUnitWithProrationPrice.invoiceGroupingKey invoicingCycleConfiguration = newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration + licenseTypeId = newSubscriptionUnitWithProrationPrice.licenseTypeId metadata = newSubscriptionUnitWithProrationPrice.metadata referenceId = newSubscriptionUnitWithProrationPrice.referenceId additionalProperties = @@ -876,6 +900,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -966,6 +1009,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -974,6 +1018,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewSubscriptionUnitWithProrationPrice = apply { if (validated) { return@apply @@ -995,6 +1047,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -1031,6 +1084,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -1145,6 +1199,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -1266,6 +1329,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ModelType = apply { if (validated) { return@apply @@ -1425,6 +1497,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitWithProrationConfig = apply { if (validated) { return@apply @@ -1531,6 +1612,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1594,6 +1684,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -1617,6 +1708,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -1626,5 +1718,5 @@ 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, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt index 1cf36751a..6f14b3286 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxJarConfiguration.kt @@ -229,6 +229,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewTaxJarConfiguration = apply { if (validated) { return@apply @@ -342,6 +350,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TaxProvider = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt index 5ee52e52c..8731581b5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewUsageDiscount.kt @@ -509,6 +509,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): NewUsageDiscount = apply { if (validated) { return@apply @@ -635,6 +643,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -754,6 +771,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AppliesToAll = apply { if (validated) { return@apply @@ -994,6 +1020,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1133,6 +1168,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1262,6 +1307,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -1429,6 +1484,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt index cdb02159a..08a310814 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/OtherSubLineItem.kt @@ -261,6 +261,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): OtherSubLineItem = apply { if (validated) { return@apply @@ -375,6 +383,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt index 8c89bd5d8..03d1e6d48 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfig.kt @@ -178,6 +178,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PackageConfig = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt index 9b069b6cf..77700956a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt @@ -165,6 +165,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PaginationMetadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt index 6cff962a3..cad6e329a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PerPriceCost.kt @@ -225,6 +225,13 @@ private constructor( fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) @@ -305,6 +312,14 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: Price.MinimumComposite) = price(Price.ofMinimumComposite(minimumComposite)) @@ -416,6 +431,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PerPriceCost = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt index a63428c14..01f04b204 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt @@ -324,6 +324,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PercentageDiscount = apply { if (validated) { return@apply @@ -441,6 +449,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -681,6 +698,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -820,6 +846,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -949,6 +985,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt index e2b9e3e69..c8638b557 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountInterval.kt @@ -375,6 +375,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PercentageDiscountInterval = apply { if (validated) { return@apply @@ -494,6 +502,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -734,6 +751,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -873,6 +899,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1002,6 +1038,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply 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 d61857e4a..067b96677 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 @@ -1171,6 +1171,13 @@ private constructor( fun addPrice(matrixWithAllocation: Price.MatrixWithAllocation) = addPrice(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [addPrice] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun addPrice(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + addPrice(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** Alias for calling [addPrice] with `Price.ofTieredWithProration(tieredWithProration)`. */ fun addPrice(tieredWithProration: Price.TieredWithProration) = addPrice(Price.ofTieredWithProration(tieredWithProration)) @@ -1253,6 +1260,16 @@ private constructor( fun addPrice(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = addPrice(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [addPrice] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun addPrice(dailyCreditAllowance: Price.DailyCreditAllowance) = + addPrice(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [addPrice] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun addPrice(meteredAllowance: Price.MeteredAllowance) = + addPrice(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [addPrice] with `Price.ofMinimumComposite(minimumComposite)`. */ fun addPrice(minimumComposite: Price.MinimumComposite) = addPrice(Price.ofMinimumComposite(minimumComposite)) @@ -1392,6 +1409,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Plan = apply { if (validated) { return@apply @@ -1514,6 +1539,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitUsageDiscount(PlanPhaseUsageDiscountAdjustment usageDiscount) { + * return Optional.of(usageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) @@ -1526,6 +1580,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -1959,6 +2022,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BasePlan = apply { if (validated) { return@apply @@ -2075,6 +2147,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -2692,6 +2773,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PlanPhase = apply { if (validated) { return@apply @@ -2848,6 +2938,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DurationUnit = apply { if (validated) { return@apply @@ -3110,6 +3210,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Product = apply { if (validated) { return@apply @@ -3255,6 +3364,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply @@ -3459,6 +3577,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TrialConfig = apply { if (validated) { return@apply @@ -3574,6 +3701,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TrialPeriodUnit = apply { if (validated) { return@apply 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 83f76051e..172b3f445 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 @@ -81,6 +81,14 @@ private constructor( */ fun defaultInvoiceMemo(): Optional = body.defaultInvoiceMemo() + /** + * An optional user-defined description of the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun description(): Optional = body.description() + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). @@ -160,6 +168,13 @@ private constructor( */ fun _defaultInvoiceMemo(): JsonField = body._defaultInvoiceMemo() + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + /** * Returns the raw JSON value of [externalPlanId]. * @@ -341,6 +356,21 @@ private constructor( body.defaultInvoiceMemo(defaultInvoiceMemo) } + /** An optional user-defined description of the plan. */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + fun externalPlanId(externalPlanId: String?) = apply { body.externalPlanId(externalPlanId) } /** Alias for calling [Builder.externalPlanId] with `externalPlanId.orElse(null)`. */ @@ -591,6 +621,7 @@ private constructor( private val prices: JsonField>, private val adjustments: JsonField>, private val defaultInvoiceMemo: JsonField, + private val description: JsonField, private val externalPlanId: JsonField, private val metadata: JsonField, private val netTerms: JsonField, @@ -614,6 +645,9 @@ private constructor( @JsonProperty("default_invoice_memo") @ExcludeMissing defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), @JsonProperty("external_plan_id") @ExcludeMissing externalPlanId: JsonField = JsonMissing.of(), @@ -631,6 +665,7 @@ private constructor( prices, adjustments, defaultInvoiceMemo, + description, externalPlanId, metadata, netTerms, @@ -680,6 +715,14 @@ private constructor( fun defaultInvoiceMemo(): Optional = defaultInvoiceMemo.getOptional("default_invoice_memo") + /** + * An optional user-defined description of the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -763,6 +806,15 @@ private constructor( @ExcludeMissing fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + /** * Returns the raw JSON value of [externalPlanId]. * @@ -838,6 +890,7 @@ private constructor( private var prices: JsonField>? = null private var adjustments: JsonField>? = null private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() private var externalPlanId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var netTerms: JsonField = JsonMissing.of() @@ -852,6 +905,7 @@ private constructor( prices = body.prices.map { it.toMutableList() } adjustments = body.adjustments.map { it.toMutableList() } defaultInvoiceMemo = body.defaultInvoiceMemo + description = body.description externalPlanId = body.externalPlanId metadata = body.metadata netTerms = body.netTerms @@ -968,6 +1022,23 @@ private constructor( this.defaultInvoiceMemo = defaultInvoiceMemo } + /** An optional user-defined description of the plan. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + fun externalPlanId(externalPlanId: String?) = externalPlanId(JsonField.ofNullable(externalPlanId)) @@ -1119,6 +1190,7 @@ private constructor( checkRequired("prices", prices).map { it.toImmutable() }, (adjustments ?: JsonMissing.of()).map { it.toImmutable() }, defaultInvoiceMemo, + description, externalPlanId, metadata, netTerms, @@ -1130,6 +1202,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1140,6 +1221,7 @@ private constructor( prices().forEach { it.validate() } adjustments().ifPresent { it.forEach { it.validate() } } defaultInvoiceMemo() + description() externalPlanId() metadata().ifPresent { it.validate() } netTerms() @@ -1169,6 +1251,7 @@ private constructor( (prices.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (adjustments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (defaultInvoiceMemo.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + (if (externalPlanId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (netTerms.asKnown().isPresent) 1 else 0) + @@ -1186,6 +1269,7 @@ private constructor( prices == other.prices && adjustments == other.adjustments && defaultInvoiceMemo == other.defaultInvoiceMemo && + description == other.description && externalPlanId == other.externalPlanId && metadata == other.metadata && netTerms == other.netTerms && @@ -1201,6 +1285,7 @@ private constructor( prices, adjustments, defaultInvoiceMemo, + description, externalPlanId, metadata, netTerms, @@ -1213,13 +1298,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{currency=$currency, name=$name, prices=$prices, adjustments=$adjustments, defaultInvoiceMemo=$defaultInvoiceMemo, externalPlanId=$externalPlanId, metadata=$metadata, netTerms=$netTerms, planPhases=$planPhases, status=$status, additionalProperties=$additionalProperties}" + "Body{currency=$currency, name=$name, prices=$prices, adjustments=$adjustments, defaultInvoiceMemo=$defaultInvoiceMemo, description=$description, externalPlanId=$externalPlanId, metadata=$metadata, netTerms=$netTerms, planPhases=$planPhases, status=$status, additionalProperties=$additionalProperties}" } class Price @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allocationPrice: JsonField, + private val licenseAllocationPrice: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, private val additionalProperties: MutableMap, @@ -1230,11 +1316,14 @@ private constructor( @JsonProperty("allocation_price") @ExcludeMissing allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("license_allocation_price") + @ExcludeMissing + licenseAllocationPrice: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - ) : this(allocationPrice, planPhaseOrder, price, mutableMapOf()) + ) : this(allocationPrice, licenseAllocationPrice, planPhaseOrder, price, mutableMapOf()) /** * The allocation price to add to the plan. @@ -1245,6 +1334,15 @@ private constructor( fun allocationPrice(): Optional = allocationPrice.getOptional("allocation_price") + /** + * The license allocation price to add to the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseAllocationPrice(): Optional = + licenseAllocationPrice.getOptional("license_allocation_price") + /** * The phase to add this price to. * @@ -1271,6 +1369,16 @@ private constructor( @ExcludeMissing fun _allocationPrice(): JsonField = allocationPrice + /** + * Returns the raw JSON value of [licenseAllocationPrice]. + * + * Unlike [licenseAllocationPrice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocation_price") + @ExcludeMissing + fun _licenseAllocationPrice(): JsonField = licenseAllocationPrice + /** * Returns the raw JSON value of [planPhaseOrder]. * @@ -1310,6 +1418,7 @@ private constructor( class Builder internal constructor() { private var allocationPrice: JsonField = JsonMissing.of() + private var licenseAllocationPrice: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1317,6 +1426,7 @@ private constructor( @JvmSynthetic internal fun from(price: Price) = apply { allocationPrice = price.allocationPrice + licenseAllocationPrice = price.licenseAllocationPrice planPhaseOrder = price.planPhaseOrder this.price = price.price additionalProperties = price.additionalProperties.toMutableMap() @@ -1341,6 +1451,29 @@ private constructor( this.allocationPrice = allocationPrice } + /** The license allocation price to add to the plan. */ + fun licenseAllocationPrice(licenseAllocationPrice: LicenseAllocationPrice?) = + licenseAllocationPrice(JsonField.ofNullable(licenseAllocationPrice)) + + /** + * Alias for calling [Builder.licenseAllocationPrice] with + * `licenseAllocationPrice.orElse(null)`. + */ + fun licenseAllocationPrice(licenseAllocationPrice: Optional) = + licenseAllocationPrice(licenseAllocationPrice.getOrNull()) + + /** + * Sets [Builder.licenseAllocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocationPrice] with a well-typed + * [LicenseAllocationPrice] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocationPrice(licenseAllocationPrice: JsonField) = + apply { + this.licenseAllocationPrice = licenseAllocationPrice + } + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -1447,6 +1580,13 @@ private constructor( fun price(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = price(InnerPrice.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `InnerPrice.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: InnerPrice.MatrixWithThresholdDiscounts) = + price(InnerPrice.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with * `InnerPrice.ofTieredWithProration(tieredWithProration)`. @@ -1543,6 +1683,17 @@ private constructor( fun price(cumulativeGroupedAllocation: InnerPrice.CumulativeGroupedAllocation) = price(InnerPrice.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with + * `InnerPrice.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: InnerPrice.DailyCreditAllowance) = + price(InnerPrice.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `InnerPrice.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: InnerPrice.MeteredAllowance) = + price(InnerPrice.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `InnerPrice.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: NewPlanMinimumCompositePrice) = price(InnerPrice.ofMinimumComposite(minimumComposite)) @@ -1579,17 +1730,33 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Price = - Price(allocationPrice, planPhaseOrder, price, additionalProperties.toMutableMap()) + Price( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Price = apply { if (validated) { return@apply } allocationPrice().ifPresent { it.validate() } + licenseAllocationPrice().ifPresent { it.validate() } planPhaseOrder() price().ifPresent { it.validate() } validated = true @@ -1612,518 +1779,1184 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (licenseAllocationPrice.asKnown().getOrNull()?.validity() ?: 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) - /** New plan price request body params. */ - @JsonDeserialize(using = InnerPrice.Deserializer::class) - @JsonSerialize(using = InnerPrice.Serializer::class) - class InnerPrice + /** The license allocation price to add to the plan. */ + class LicenseAllocationPrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unit: NewPlanUnitPrice? = null, - private val tiered: NewPlanTieredPrice? = null, - private val bulk: NewPlanBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewPlanPackagePrice? = null, - private val matrix: NewPlanMatrixPrice? = null, - private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val tieredPackage: NewPlanTieredPackagePrice? = null, - private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val groupedTiered: NewPlanGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewPlanUnitWithProrationPrice? = null, - private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, - private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewPlanMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, + private val cadence: JsonField, + private val itemId: JsonField, + private val licenseAllocations: JsonField>, + private val modelType: JsonField, + private val name: JsonField, + private val unitConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, ) { - fun unit(): Optional = Optional.ofNullable(unit) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("license_allocations") + @ExcludeMissing + licenseAllocations: JsonField> = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + licenseAllocations, + modelType, + name, + unitConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - fun tiered(): Optional = Optional.ofNullable(tiered) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun bulk(): Optional = Optional.ofNullable(bulk) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + /** + * License allocations to associate with this price. Each entry defines a per-license + * credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun licenseAllocations(): List = + licenseAllocations.getRequired("license_allocations") - fun package_(): Optional = Optional.ofNullable(package_) + /** + * The pricing model type + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun modelType(): ModelType = modelType.getRequired("model_type") - fun matrix(): Optional = Optional.ofNullable(matrix) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + /** + * Configuration for unit pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - fun groupedWithProratedMinimum(): Optional = - Optional.ofNullable(groupedWithProratedMinimum) + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - fun groupedWithMeteredMinimum(): Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - fun groupedWithMinMaxThresholds(): Optional = - Optional.ofNullable(groupedWithMinMaxThresholds) + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + /** + * Returns the raw JSON value of [licenseAllocations]. + * + * Unlike [licenseAllocations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_allocations") + @ExcludeMissing + fun _licenseAllocations(): JsonField> = licenseAllocations - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + /** + * 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 - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + /** + * Returns the raw JSON value of [unitConfig]. + * + * Unlike [unitConfig], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig - fun cumulativeGroupedAllocation(): Optional = - Optional.ofNullable(cumulativeGroupedAllocation) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun minimumComposite(): Optional = - Optional.ofNullable(minimumComposite) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun percent(): Optional = Optional.ofNullable(percent) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun isUnit(): Boolean = unit != null + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - fun isTiered(): Boolean = tiered != null + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - fun isBulk(): Boolean = bulk != null + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun isPackage(): Boolean = package_ != null + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isMatrix(): Boolean = matrix != null + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + fun toBuilder() = Builder().from(this) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + companion object { - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isUnitWithProration(): Boolean = unitWithProration != null + /** A builder for [LicenseAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var licenseAllocations: JsonField>? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun isGroupedAllocation(): Boolean = groupedAllocation != null + @JvmSynthetic + internal fun from(licenseAllocationPrice: LicenseAllocationPrice) = apply { + cadence = licenseAllocationPrice.cadence + itemId = licenseAllocationPrice.itemId + licenseAllocations = + licenseAllocationPrice.licenseAllocations.map { it.toMutableList() } + modelType = licenseAllocationPrice.modelType + name = licenseAllocationPrice.name + unitConfig = licenseAllocationPrice.unitConfig + billableMetricId = licenseAllocationPrice.billableMetricId + billedInAdvance = licenseAllocationPrice.billedInAdvance + billingCycleConfiguration = licenseAllocationPrice.billingCycleConfiguration + conversionRate = licenseAllocationPrice.conversionRate + conversionRateConfig = licenseAllocationPrice.conversionRateConfig + currency = licenseAllocationPrice.currency + dimensionalPriceConfiguration = + licenseAllocationPrice.dimensionalPriceConfiguration + externalPriceId = licenseAllocationPrice.externalPriceId + fixedPriceQuantity = licenseAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = licenseAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = licenseAllocationPrice.invoicingCycleConfiguration + licenseTypeId = licenseAllocationPrice.licenseTypeId + metadata = licenseAllocationPrice.metadata + referenceId = licenseAllocationPrice.referenceId + additionalProperties = + licenseAllocationPrice.additionalProperties.toMutableMap() + } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** + * License allocations to associate with this price. Each entry defines a + * per-license credit pool granted each cadence. Requires license_type_id or + * license_type_configuration to be set. + */ + fun licenseAllocations(licenseAllocations: List) = + licenseAllocations(JsonField.of(licenseAllocations)) - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Sets [Builder.licenseAllocations] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseAllocations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun licenseAllocations(licenseAllocations: JsonField>) = + apply { + this.licenseAllocations = licenseAllocations.map { it.toMutableList() } + } - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * Adds a single [LicenseAllocation] to [licenseAllocations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicenseAllocation(licenseAllocation: LicenseAllocation) = apply { + licenseAllocations = + (licenseAllocations ?: JsonField.of(mutableListOf())).also { + checkKnown("licenseAllocations", it).add(licenseAllocation) + } + } - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** The pricing model type */ + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Sets [Builder.modelType] to an arbitrary JSON value. + * + * You should usually call [Builder.modelType] with a well-typed [ModelType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun isMinimumComposite(): Boolean = minimumComposite != null + /** Configuration for unit pricing */ + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - fun isPercent(): Boolean = percent != null + /** + * Sets [Builder.unitConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitConfig] with a well-typed [UnitConfig] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } - fun isEventOutput(): Boolean = eventOutput != null + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun asTieredPackage(): NewPlanTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun asGroupedTiered(): NewPlanGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun asUnitWithProration(): NewPlanUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } - fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun asBulkWithProration(): NewPlanBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") - - fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - - fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) - fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = - cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun asMinimumComposite(): NewPlanMinimumCompositePrice = - minimumComposite.getOrThrow("minimumComposite") + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun asPercent(): Percent = percent.getOrThrow("percent") + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun _json(): Optional = Optional.ofNullable(_json) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - cumulativeGroupedAllocation != null -> - visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) - minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - private var validated: Boolean = false + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - fun validate(): InnerPrice = apply { - if (validated) { - return@apply + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) { - unit.validate() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun visitTiered(tiered: NewPlanTieredPrice) { - tiered.validate() - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - override fun visitBulk(bulk: NewPlanBulkPrice) { - bulk.validate() - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - override fun visitPackage(package_: NewPlanPackagePrice) { - package_.validate() - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - override fun visitMatrix(matrix: NewPlanMatrixPrice) { - matrix.validate() - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { - tieredPackage.validate() - } + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { - groupedTiered.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) { - unitWithProration.validate() - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } - - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } - - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } - - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } - - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } - - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } - - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } - - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) { - cumulativeGroupedAllocation.validate() - } + /** + * Returns an immutable instance of [LicenseAllocationPrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .licenseAllocations() + * .modelType() + * .name() + * .unitConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocationPrice = + LicenseAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("licenseAllocations", licenseAllocations).map { + it.toImmutable() + }, + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) { - minimumComposite.validate() - } + private var validated: Boolean = false - override fun visitPercent(percent: Percent) { - percent.validate() - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseAllocationPrice = apply { + if (validated) { + return@apply + } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } - } - ) + cadence().validate() + itemId() + licenseAllocations().forEach { it.validate() } + modelType().validate() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() validated = true } @@ -2143,873 +2976,769 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() - - override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (licenseAllocations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (modelType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + companion object { - override fun visitPackage(package_: NewPlanPackagePrice) = - package_.validity() + @JvmField val ANNUAL = of("annual") - override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + @JvmField val SEMI_ANNUAL = of("semi_annual") - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + @JvmField val MONTHLY = of("monthly") - override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - tieredPackage.validity() + @JvmField val QUARTERLY = of("quarterly") - override fun visitTieredWithMinimum( - tieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + @JvmField val ONE_TIME = of("one_time") - override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - groupedTiered.validity() + @JvmField val CUSTOM = of("custom") - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - override fun visitUnitWithPercent( - unitWithPercent: NewPlanUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - override fun visitUnitWithProration( - unitWithProration: NewPlanUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - override fun visitGroupedAllocation( - groupedAllocation: NewPlanGroupedAllocationPrice - ) = groupedAllocation.validity() + private var validated: Boolean = false - override fun visitBulkWithProration( - bulkWithProration: NewPlanBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + known() + validated = true + } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + return other is Cadence && value == other.value + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + override fun hashCode() = value.hashCode() - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + override fun toString() = value.toString() + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + class LicenseAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val writeOffOverage: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("write_off_overage") + @ExcludeMissing + writeOffOverage: JsonField = JsonMissing.of(), + ) : this(amount, currency, writeOffOverage, mutableMapOf()) - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = cumulativeGroupedAllocation.validity() + /** + * The amount of credits granted per active license per cadence. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun amount(): String = amount.getRequired("amount") - override fun visitMinimumComposite( - minimumComposite: NewPlanMinimumCompositePrice - ) = minimumComposite.validity() + /** + * The currency of the license allocation. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") - override fun visitPercent(percent: Percent) = percent.validity() + /** + * When True, overage beyond the allocation is written off. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun writeOffOverage(): Optional = + writeOffOverage.getOptional("write_off_overage") - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - return other is InnerPrice && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && - minimumComposite == other.minimumComposite && - percent == other.percent && - eventOutput == other.eventOutput - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - cumulativeGroupedAllocation, - minimumComposite, - percent, - eventOutput, - ) + /** + * Returns the raw JSON value of [writeOffOverage]. + * + * Unlike [writeOffOverage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("write_off_overage") + @ExcludeMissing + fun _writeOffOverage(): JsonField = writeOffOverage - override fun toString(): String = - when { - unit != null -> "InnerPrice{unit=$unit}" - tiered != null -> "InnerPrice{tiered=$tiered}" - bulk != null -> "InnerPrice{bulk=$bulk}" - bulkWithFilters != null -> "InnerPrice{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "InnerPrice{package_=$package_}" - matrix != null -> "InnerPrice{matrix=$matrix}" - thresholdTotalAmount != null -> - "InnerPrice{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "InnerPrice{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "InnerPrice{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "InnerPrice{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "InnerPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "InnerPrice{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "InnerPrice{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "InnerPrice{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> - "InnerPrice{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "InnerPrice{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "InnerPrice{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "InnerPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "InnerPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "InnerPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "InnerPrice{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "InnerPrice{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "InnerPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "InnerPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "InnerPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - cumulativeGroupedAllocation != null -> - "InnerPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "InnerPrice{minimumComposite=$minimumComposite}" - percent != null -> "InnerPrice{percent=$percent}" - eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" - _json != null -> "InnerPrice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid InnerPrice") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = InnerPrice(unit = unit) + fun toBuilder() = Builder().from(this) - @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = InnerPrice(tiered = tiered) + companion object { - @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) + /** + * Returns a mutable builder for constructing an instance of + * [LicenseAllocation]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - InnerPrice(bulkWithFilters = bulkWithFilters) + /** A builder for [LicenseAllocation]. */ + class Builder internal constructor() { - @JvmStatic - fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) + private var amount: JsonField? = null + private var currency: JsonField? = null + private var writeOffOverage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) + @JvmSynthetic + internal fun from(licenseAllocation: LicenseAllocation) = apply { + amount = licenseAllocation.amount + currency = licenseAllocation.currency + writeOffOverage = licenseAllocation.writeOffOverage + additionalProperties = licenseAllocation.additionalProperties.toMutableMap() + } - @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = - InnerPrice(thresholdTotalAmount = thresholdTotalAmount) + /** The amount of credits granted per active license per cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) - @JvmStatic - fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = - InnerPrice(tieredPackage = tieredPackage) + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = - InnerPrice(tieredWithMinimum = tieredWithMinimum) + /** The currency of the license allocation. */ + fun currency(currency: String) = currency(JsonField.of(currency)) - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = - InnerPrice(groupedTiered = groupedTiered) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** When True, overage beyond the allocation is written off. */ + fun writeOffOverage(writeOffOverage: Boolean?) = + writeOffOverage(JsonField.ofNullable(writeOffOverage)) - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ) = InnerPrice(packageWithAllocation = packageWithAllocation) + /** + * Alias for [Builder.writeOffOverage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun writeOffOverage(writeOffOverage: Boolean) = + writeOffOverage(writeOffOverage as Boolean?) - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = - InnerPrice(unitWithPercent = unitWithPercent) + /** + * Alias for calling [Builder.writeOffOverage] with + * `writeOffOverage.orElse(null)`. + */ + fun writeOffOverage(writeOffOverage: Optional) = + writeOffOverage(writeOffOverage.getOrNull()) - @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = - InnerPrice(matrixWithAllocation = matrixWithAllocation) + /** + * Sets [Builder.writeOffOverage] to an arbitrary JSON value. + * + * You should usually call [Builder.writeOffOverage] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun writeOffOverage(writeOffOverage: JsonField) = apply { + this.writeOffOverage = writeOffOverage + } - @JvmStatic - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - InnerPrice(tieredWithProration = tieredWithProration) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = - InnerPrice(unitWithProration = unitWithProration) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = - InnerPrice(groupedAllocation = groupedAllocation) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = - InnerPrice(bulkWithProration = bulkWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = InnerPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) - - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = InnerPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmStatic - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = InnerPrice(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** + * Returns an immutable instance of [LicenseAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseAllocation = + LicenseAllocation( + checkRequired("amount", amount), + checkRequired("currency", currency), + writeOffOverage, + additionalProperties.toMutableMap(), + ) + } - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = InnerPrice(matrixWithDisplayName = matrixWithDisplayName) + private var validated: Boolean = false - @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = - InnerPrice(groupedTieredPackage = groupedTieredPackage) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): LicenseAllocation = apply { + if (validated) { + return@apply + } - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = InnerPrice(maxGroupTieredPackage = maxGroupTieredPackage) + amount() + currency() + writeOffOverage() + validated = true + } - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = InnerPrice(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = InnerPrice(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (writeOffOverage.asKnown().isPresent) 1 else 0) - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic - fun ofCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = InnerPrice(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + return other is LicenseAllocation && + amount == other.amount && + currency == other.currency && + writeOffOverage == other.writeOffOverage && + additionalProperties == other.additionalProperties + } - @JvmStatic - fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = - InnerPrice(minimumComposite = minimumComposite) + private val hashCode: Int by lazy { + Objects.hash(amount, currency, writeOffOverage, additionalProperties) + } - @JvmStatic fun ofPercent(percent: Percent) = InnerPrice(percent = percent) + override fun hashCode(): Int = hashCode - @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = InnerPrice(eventOutput = eventOutput) + override fun toString() = + "LicenseAllocation{amount=$amount, currency=$currency, writeOffOverage=$writeOffOverage, additionalProperties=$additionalProperties}" } - /** - * An interface that defines how to map each variant of [InnerPrice] to a value of type - * [T]. - */ - interface Visitor { + /** The pricing model type */ + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun visitUnit(unit: NewPlanUnitPrice): T + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun visitTiered(tiered: NewPlanTieredPrice): T + companion object { - fun visitBulk(bulk: NewPlanBulkPrice): T + @JvmField val UNIT = of("unit") - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } - fun visitPackage(package_: NewPlanPackagePrice): T + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT + } - fun visitMatrix(matrix: NewPlanMatrixPrice): T + /** + * 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, + } - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT -> Value.UNIT + else -> Value._UNKNOWN + } - fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT -> Known.UNIT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + private var validated: Boolean = false - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice - ): T + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ModelType = apply { + if (validated) { + return@apply + } - fun visitPackageWithAllocation( - packageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + known() + validated = true + } - fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun visitMatrixWithAllocation( - matrixWithAllocation: NewPlanMatrixWithAllocationPrice - ): T + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + return other is ModelType && value == other.value + } - fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + override fun hashCode() = value.hashCode() - fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + override fun toString() = value.toString() + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ): T + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + fun toBuilder() = Builder().from(this) - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + companion object { - fun visitGroupedTieredPackage( - groupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ): T + private var additionalProperties: MutableMap = mutableMapOf() - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ): T + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitPercent(percent: Percent): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitEventOutput(eventOutput: EventOutput): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Maps an unknown variant of [InnerPrice] to a value of type [T]. + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. * - * An instance of [InnerPrice] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException in the default implementation. + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown InnerPrice: $json") + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - internal class Deserializer : BaseDeserializer(InnerPrice::class) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun ObjectCodec.deserialize(node: JsonNode): InnerPrice { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + return other is LicenseAllocationPrice && + cadence == other.cadence && + itemId == other.itemId && + licenseAllocations == other.licenseAllocations && + modelType == other.modelType && + name == other.name && + unitConfig == other.unitConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(unit = it, _json = json) - } ?: InnerPrice(_json = json) - } - "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(tiered = it, _json = json) - } ?: InnerPrice(_json = json) - } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(bulk = it, _json = json) - } ?: InnerPrice(_json = json) - } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(bulkWithFilters = it, _json = json) - } ?: InnerPrice(_json = json) - } - "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(package_ = it, _json = json) } - ?: InnerPrice(_json = json) - } - "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(matrix = it, _json = json) - } ?: InnerPrice(_json = json) - } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(thresholdTotalAmount = it, _json = json) } - ?: InnerPrice(_json = json) - } - "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(tieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) - } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(tieredWithMinimum = it, _json = json) } - ?: InnerPrice(_json = json) - } - "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(groupedTiered = it, _json = json) } - ?: InnerPrice(_json = json) - } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } - ?: InnerPrice(_json = json) - } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(packageWithAllocation = it, _json = json) } - ?: InnerPrice(_json = json) - } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(unitWithPercent = it, _json = json) } - ?: InnerPrice(_json = json) - } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } - ?: InnerPrice(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { InnerPrice(tieredWithProration = it, _json = json) } - ?: InnerPrice(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(unitWithProration = it, _json = json) } - ?: InnerPrice(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedAllocation = it, _json = json) } - ?: InnerPrice(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(bulkWithProration = it, _json = json) } - ?: InnerPrice(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedWithProratedMinimum = it, _json = json) } - ?: InnerPrice(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedWithMeteredMinimum = it, _json = json) } - ?: InnerPrice(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedWithMinMaxThresholds = it, _json = json) } - ?: InnerPrice(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(matrixWithDisplayName = it, _json = json) } - ?: InnerPrice(_json = json) - } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(groupedTieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) - } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(maxGroupTieredPackage = it, _json = json) } - ?: InnerPrice(_json = json) - } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - InnerPrice(scalableMatrixWithUnitPricing = it, _json = json) - } ?: InnerPrice(_json = json) - } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - InnerPrice(scalableMatrixWithTieredPricing = it, _json = json) - } ?: InnerPrice(_json = json) - } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(cumulativeGroupedBulk = it, _json = json) } - ?: InnerPrice(_json = json) - } - "cumulative_grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(cumulativeGroupedAllocation = it, _json = json) } - ?: InnerPrice(_json = json) - } - "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { InnerPrice(minimumComposite = it, _json = json) } - ?: InnerPrice(_json = json) - } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(percent = it, _json = json) - } ?: InnerPrice(_json = json) - } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - InnerPrice(eventOutput = it, _json = json) - } ?: InnerPrice(_json = json) - } - } - - return InnerPrice(_json = json) - } - } - - internal class Serializer : BaseSerializer(InnerPrice::class) { - - override fun serialize( - value: InnerPrice, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.cumulativeGroupedAllocation != null -> - generator.writeObject(value.cumulativeGroupedAllocation) - value.minimumComposite != null -> - generator.writeObject(value.minimumComposite) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid InnerPrice") - } - } - } - - class BulkWithFilters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val bulkWithFiltersConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bulkWithFiltersConfig, + private val hashCode: Int by lazy { + Objects.hash( cadence, itemId, + licenseAllocations, modelType, name, + unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -3021,1845 +3750,10069 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, - mutableMapOf(), + additionalProperties, ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseAllocationPrice{cadence=$cadence, itemId=$itemId, licenseAllocations=$licenseAllocations, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + /** New plan price request body params. */ + @JsonDeserialize(using = InnerPrice.Deserializer::class) + @JsonSerialize(using = InnerPrice.Serializer::class) + class InnerPrice + private constructor( + private val unit: NewPlanUnitPrice? = null, + private val tiered: NewPlanTieredPrice? = null, + private val bulk: NewPlanBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewPlanPackagePrice? = null, + private val matrix: NewPlanMatrixPrice? = null, + private val thresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, + private val tieredPackage: NewPlanTieredPackagePrice? = null, + private val tieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, + private val groupedTiered: NewPlanGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice? = null, + private val packageWithAllocation: NewPlanPackageWithAllocationPrice? = null, + private val unitWithPercent: NewPlanUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewPlanMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewPlanUnitWithProrationPrice? = null, + private val groupedAllocation: NewPlanGroupedAllocationPrice? = null, + private val bulkWithProration: NewPlanBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, + private val minimumComposite: NewPlanMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewPlanUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewPlanTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewPlanBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewPlanPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewPlanMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewPlanTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewPlanTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewPlanGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewPlanTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewPlanPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewPlanUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewPlanMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewPlanUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewPlanGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewPlanBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): NewPlanScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + + fun asMinimumComposite(): NewPlanMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = innerPrice.accept(new InnerPrice.Visitor>() { + * @Override + * public Optional visitUnit(NewPlanUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): InnerPrice = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewPlanTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewPlanBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewPlanPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewPlanMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewPlanUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewPlanTieredPrice) = tiered.validity() + + override fun visitBulk(bulk: NewPlanBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewPlanPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewPlanMatrixPrice) = matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewPlanTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewPlanUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewPlanUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewPlanGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewPlanBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewPlanScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + + override fun visitMinimumComposite( + minimumComposite: NewPlanMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerPrice && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + matrixWithThresholdDiscounts, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "InnerPrice{unit=$unit}" + tiered != null -> "InnerPrice{tiered=$tiered}" + bulk != null -> "InnerPrice{bulk=$bulk}" + bulkWithFilters != null -> "InnerPrice{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "InnerPrice{package_=$package_}" + matrix != null -> "InnerPrice{matrix=$matrix}" + thresholdTotalAmount != null -> + "InnerPrice{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "InnerPrice{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "InnerPrice{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "InnerPrice{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "InnerPrice{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "InnerPrice{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "InnerPrice{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "InnerPrice{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "InnerPrice{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" + tieredWithProration != null -> + "InnerPrice{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "InnerPrice{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "InnerPrice{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "InnerPrice{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "InnerPrice{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "InnerPrice{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "InnerPrice{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "InnerPrice{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "InnerPrice{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "InnerPrice{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "InnerPrice{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "InnerPrice{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "InnerPrice{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "InnerPrice{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "InnerPrice{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "InnerPrice{meteredAllowance=$meteredAllowance}" + minimumComposite != null -> "InnerPrice{minimumComposite=$minimumComposite}" + percent != null -> "InnerPrice{percent=$percent}" + eventOutput != null -> "InnerPrice{eventOutput=$eventOutput}" + _json != null -> "InnerPrice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InnerPrice") + } + + companion object { + + @JvmStatic fun ofUnit(unit: NewPlanUnitPrice) = InnerPrice(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewPlanTieredPrice) = InnerPrice(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewPlanBulkPrice) = InnerPrice(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + InnerPrice(bulkWithFilters = bulkWithFilters) + + @JvmStatic + fun ofPackage(package_: NewPlanPackagePrice) = InnerPrice(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewPlanMatrixPrice) = InnerPrice(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount(thresholdTotalAmount: NewPlanThresholdTotalAmountPrice) = + InnerPrice(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewPlanTieredPackagePrice) = + InnerPrice(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice) = + InnerPrice(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice) = + InnerPrice(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ) = InnerPrice(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ) = InnerPrice(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice) = + InnerPrice(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation(matrixWithAllocation: NewPlanMatrixWithAllocationPrice) = + InnerPrice(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = InnerPrice(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + InnerPrice(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice) = + InnerPrice(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice) = + InnerPrice(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice) = + InnerPrice(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ) = InnerPrice(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ) = InnerPrice(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = InnerPrice(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ) = InnerPrice(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage(groupedTieredPackage: NewPlanGroupedTieredPackagePrice) = + InnerPrice(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ) = InnerPrice(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ) = InnerPrice(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ) = InnerPrice(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ) = InnerPrice(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = InnerPrice(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + InnerPrice(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + InnerPrice(meteredAllowance = meteredAllowance) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice) = + InnerPrice(minimumComposite = minimumComposite) + + @JvmStatic fun ofPercent(percent: Percent) = InnerPrice(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = InnerPrice(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [InnerPrice] to a value of type + * [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewPlanUnitPrice): T + + fun visitTiered(tiered: NewPlanTieredPrice): T + + fun visitBulk(bulk: NewPlanBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewPlanPackagePrice): T + + fun visitMatrix(matrix: NewPlanMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewPlanThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewPlanTieredPackagePrice): T + + fun visitTieredWithMinimum(tieredWithMinimum: NewPlanTieredWithMinimumPrice): T + + fun visitGroupedTiered(groupedTiered: NewPlanGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewPlanTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewPlanPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewPlanUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewPlanMatrixWithAllocationPrice + ): T + + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration(unitWithProration: NewPlanUnitWithProrationPrice): T + + fun visitGroupedAllocation(groupedAllocation: NewPlanGroupedAllocationPrice): T + + fun visitBulkWithProration(bulkWithProration: NewPlanBulkWithProrationPrice): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewPlanGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + + fun visitMinimumComposite(minimumComposite: NewPlanMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [InnerPrice] to a value of type [T]. + * + * An instance of [InnerPrice] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown InnerPrice: $json") + } + } + + internal class Deserializer : BaseDeserializer(InnerPrice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InnerPrice { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(unit = it, _json = json) + } ?: InnerPrice(_json = json) + } + "tiered" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(tiered = it, _json = json) + } ?: InnerPrice(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(bulk = it, _json = json) + } ?: InnerPrice(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(bulkWithFilters = it, _json = json) + } ?: InnerPrice(_json = json) + } + "package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(package_ = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(matrix = it, _json = json) + } ?: InnerPrice(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(thresholdTotalAmount = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_package" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(tieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(tieredWithMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(groupedTiered = it, _json = json) } + ?: InnerPrice(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(tieredPackageWithMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(packageWithAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(unitWithPercent = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(matrixWithAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + InnerPrice(matrixWithThresholdDiscounts = it, _json = json) + } ?: InnerPrice(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(tieredWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(unitWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(bulkWithProration = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithProratedMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithMeteredMinimum = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedWithMinMaxThresholds = it, _json = json) } + ?: InnerPrice(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(matrixWithDisplayName = it, _json = json) } + ?: InnerPrice(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(groupedTieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(maxGroupTieredPackage = it, _json = json) } + ?: InnerPrice(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + InnerPrice(scalableMatrixWithUnitPricing = it, _json = json) + } ?: InnerPrice(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + InnerPrice(scalableMatrixWithTieredPricing = it, _json = json) + } ?: InnerPrice(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(cumulativeGroupedBulk = it, _json = json) } + ?: InnerPrice(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(cumulativeGroupedAllocation = it, _json = json) } + ?: InnerPrice(_json = json) + } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { InnerPrice(dailyCreditAllowance = it, _json = json) } + ?: InnerPrice(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(meteredAllowance = it, _json = json) + } ?: InnerPrice(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { InnerPrice(minimumComposite = it, _json = json) } + ?: InnerPrice(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(percent = it, _json = json) + } ?: InnerPrice(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + InnerPrice(eventOutput = it, _json = json) + } ?: InnerPrice(_json = json) + } + } + + return InnerPrice(_json = json) + } + } + + internal class Serializer : BaseSerializer(InnerPrice::class) { + + override fun serialize( + value: InnerPrice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InnerPrice") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithThresholdDiscounts + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Configuration for matrix_with_threshold_discounts pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_threshold_discounts") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscounts]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscounts]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null + private var modelType: JsonValue = + JsonValue.from("matrix_with_threshold_discounts") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = + apply { + cadence = matrixWithThresholdDiscounts.cadence + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance + billingCycleConfiguration = + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + currency = matrixWithThresholdDiscounts.currency + dimensionalPriceConfiguration = + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata + referenceId = matrixWithThresholdDiscounts.referenceId + additionalProperties = + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + + /** + * 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_with_threshold_discounts") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired( + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + matrixWithThresholdDiscountsConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) + + /** + * Unit price used for usage that does not match any defined matrix cell. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** + * First matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Per-cell unit prices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Optional second matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscountsConfig]. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ + class Builder internal constructor() { + + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = apply { + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } + additionalProperties = + matrixWithThresholdDiscountsConfig.additionalProperties + .toMutableMap() + } + + /** + * Unit price used for usage that does not match any defined matrix cell. + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } + + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * The pricing model type - * - * Expected to always return the following: - * ```java - * JsonValue.from("bulk_with_filters") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + private var validated: Boolean = false - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + tiers().forEach { it.validate() } + validated = true + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + private var validated: Boolean = false - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + tierLowerBound() + unitAmount() + validated = true + } - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + override fun hashCode(): Int = hashCode - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun toBuilder() = Builder().from(this) + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. - * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } - /** A builder for [BulkWithFilters]. */ - class Builder internal constructor() { + /** + * User-specified key/value pairs for the resource. Individual keys can 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 + ) { - private var bulkWithFiltersConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() - } + fun toBuilder() = Builder().from(this) - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + companion object { - /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + private var additionalProperties: MutableMap = + mutableMapOf() - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("bulk_with_filters") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Alias for [Builder.billedInAdvance]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance + return other is Metadata && + additionalProperties == other.additionalProperties } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { /** - * Returns an immutable instance of [BulkWithFilters]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```java - * .bulkWithFiltersConfig() * .cadence() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BulkWithFilters = apply { - if (validated) { - return@apply - } - - bulkWithFiltersConfig().validate() - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true + @JvmStatic fun builder() = Builder() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } - @JsonCreator - private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** - * Property filters to apply (all must match) + * Sets [Builder.cadence] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun filters(): List = filters.getRequired("filters") + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) /** - * Bulk tiers for rating based on total usage volume + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - fun tiers(): List = tiers.getRequired("tiers") + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** - * Returns the raw JSON value of [filters]. + * Sets [Builder.itemId] to an arbitrary JSON value. * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } /** - * Returns the raw JSON value of [tiers]. + * Sets the field to an arbitrary JSON value. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun toBuilder() = Builder().from(this) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - companion object { + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - /** A builder for [BulkWithFiltersConfig]. */ - class Builder internal constructor() { - - private var filters: JsonField>? = null - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() - } - - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } - - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** - * Returns an immutable instance of [BulkWithFiltersConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - private var validated: Boolean = false + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun validate(): BulkWithFiltersConfig = apply { - if (validated) { - return@apply - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - filters().forEach { it.validate() } - tiers().forEach { it.validate() } - validated = true - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` */ - @JvmSynthetic - internal fun validity(): Int = - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun toBuilder() = Builder().from(this) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - companion object { + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** A builder for [Filter]. */ - class Builder internal constructor() { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - @JvmSynthetic - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - private var validated: Boolean = false + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun validate(): Filter = apply { - if (validated) { - return@apply - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - propertyKey() - propertyValue() - validated = true - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (propertyKey.asKnown().isPresent) 1 else 0) + - (if (propertyValue.asKnown().isPresent) 1 else 0) + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun hashCode(): Int = hashCode + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + private var validated: Boolean = false - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun toBuilder() = Builder().from(this) + companion object { - companion object { + @JvmField val ANNUAL = of("annual") - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - /** A builder for [Tier]. */ - class Builder internal constructor() { + @JvmField val MONTHLY = of("monthly") - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + @JvmField val QUARTERLY = of("quarterly") - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } + @JvmField val ONE_TIME = of("one_time") - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private var validated: Boolean = false - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + known() + validated = true + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private var validated: Boolean = false + return other is Cadence && value == other.value + } - fun validate(): Tier = apply { - if (validated) { - return@apply - } + override fun hashCode() = value.hashCode() - unitAmount() - tierLowerBound() - validated = true - } + override fun toString() = value.toString() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties - } + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } + fun toBuilder() = Builder().from(this) - /** The cadence to bill for this price on. */ - class Cadence - @JsonCreator - private constructor(private val value: JsonField) : Enum { + companion object { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - companion object { + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { - @JvmField val ANNUAL = of("annual") + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - @JvmField val SEMI_ANNUAL = of("semi_annual") + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } - @JvmField val MONTHLY = of("monthly") + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - @JvmField val QUARTERLY = of("quarterly") + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - @JvmField val ONE_TIME = of("one_time") + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) - @JvmField val CUSTOM = of("custom") + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, /** - * An enum member indicating that [Cadence] was instantiated with an unknown - * value. + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - _UNKNOWN, - } + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false - fun validate(): Cadence = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - known() + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -4878,19 +13831,39 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -4960,6 +13933,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -5009,9 +13992,10 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -5026,6 +14010,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -5033,8 +14018,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -5049,6 +14034,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -5058,17 +14044,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -5081,6 +14068,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -5091,6 +14079,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -5100,10 +14093,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -5140,6 +14129,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -5148,10 +14140,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -5163,6 +14155,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -5177,6 +14170,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -5191,7 +14196,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5208,16 +14213,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -5322,6 +14317,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5351,6 +14354,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -5367,17 +14381,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -5491,6 +14494,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5527,28 +14540,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -5566,35 +14581,40 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -5608,6 +14628,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -5626,7 +14669,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -5646,22 +14689,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -6010,6 +15037,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6074,27 +15122,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6106,6 +15157,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -6114,20 +15166,30 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -6139,6 +15201,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -6161,12 +15224,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -6178,6 +15241,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -6301,6 +15365,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -6340,40 +15414,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("cumulative_allocation") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [tiers]. + * The allocation per individual group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -6391,59 +15540,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -6469,32 +15659,51 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -6512,251 +15721,40 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + @JvmSynthetic + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -6826,6 +15824,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -6875,12 +15883,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -6892,6 +15901,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -6900,10 +15910,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -6915,6 +15925,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -6924,15 +15935,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class DailyCreditAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val dailyCreditAllowanceConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -6948,6 +15958,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -6958,10 +15969,9 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = + dailyCreditAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -7008,6 +16018,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7016,7 +16029,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -7031,6 +16044,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -7046,16 +16060,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for daily_credit_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") /** * The id of the item the price will be associated with. @@ -7071,7 +16083,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7192,6 +16204,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7222,15 +16242,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig /** * Returns the raw JSON value of [itemId]. @@ -7361,6 +16381,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7397,12 +16427,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [DailyCreditAllowance]. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` @@ -7410,16 +16440,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [DailyCreditAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = + private var dailyCreditAllowanceConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7438,38 +16466,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + currency = dailyCreditAllowance.currency + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + referenceId = dailyCreditAllowance.referenceId + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -7483,28 +16510,22 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -7524,7 +16545,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -7892,6 +16913,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7956,27 +16998,24 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [DailyCreditAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): DailyCreditAllowance = + DailyCreditAllowance( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -7991,6 +17030,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -7999,16 +17039,26 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + dailyCreditAllowanceConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("daily_credit_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -8024,6 +17074,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -8046,10 +17097,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -8063,6 +17114,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -8186,6 +17238,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -8225,108 +17287,144 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Credits granted per day. Lose-it-or-use-it; does not roll over. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") /** - * The maximum amount to charge each group + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The minimum amount to charge each group, regardless of usage + * One or two event property values to evaluate matrix groups by * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun dimensions(): List = dimensions.getRequired("dimensions") /** - * The base price charged per group + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") /** - * Returns the raw JSON value of [groupingKey]. + * Per-dimension credit rates * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _dailyAllowance(): JsonField = dailyAllowance /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("dimensions") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _dimensions(): JsonField> = dimensions /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [eventDayProperty]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("event_day_property") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _eventDayProperty(): JsonField = eventDayProperty /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("matrix_values") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _matrixValues(): JsonField> = matrixValues @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -8344,100 +17442,153 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [DailyCreditAllowanceConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [DailyCreditAllowanceConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } + + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) + + /** + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance + } + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** + * Sets [Builder.dimensions] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Adds a single [String] to [dimensions]. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.eventDayProperty] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) - /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Adds a single [MatrixValue] to [matrixValues]. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = @@ -8463,84 +17614,368 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + dimensionValues() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, additionalProperties, ) } @@ -8548,7 +17983,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } /** @@ -8618,6 +18053,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -8667,10 +18112,9 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is DailyCreditAllowance && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -8685,6 +18129,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8693,7 +18138,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -8708,6 +18153,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8717,16 +18163,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -8741,6 +18186,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8751,14 +18197,12 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -8801,6 +18245,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8809,8 +18256,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -8824,6 +18271,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -8839,32 +18287,30 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for metered_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -8985,6 +18431,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9014,17 +18468,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [itemId]. * @@ -9033,6 +18476,17 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + /** * Returns the raw JSON value of [name]. * @@ -9154,6 +18608,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9189,30 +18653,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -9231,38 +18691,35 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + currency = meteredAllowance.currency + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + referenceId = meteredAllowance.referenceId + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9276,29 +18733,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -9311,13 +18745,28 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + /** * 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("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9685,6 +19134,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9749,28 +19219,25 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), modelType, checkRequired("name", name), billableMetricId, @@ -9784,6 +19251,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9792,16 +19260,26 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() itemId() + meteredAllowanceConfig().validate() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -9817,6 +19295,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -9839,11 +19318,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -9856,6 +19333,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -9979,6 +19457,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -10018,60 +19506,76 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), ) : this( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, mutableMapOf(), ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -10080,7 +19584,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -10089,24 +19593,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -10128,6 +19650,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -10144,12 +19686,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -10157,61 +19699,75 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) @@ -10226,7 +19782,9 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -10240,6 +19798,37 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10263,41 +19852,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -10317,30 +19920,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -10348,7 +19957,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } /** @@ -10418,6 +20027,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -10467,11 +20086,10 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -10485,6 +20103,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -10493,8 +20112,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -10508,6 +20127,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -10517,7 +20137,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MeteredAllowance{cadence=$cadence, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -10540,6 +20160,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10598,6 +20219,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10621,6 +20245,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10779,6 +20404,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10947,6 +20580,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11020,6 +20663,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11042,6 +20686,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -11460,6 +21105,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11556,6 +21222,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -11564,6 +21231,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -11589,6 +21266,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -11626,6 +21304,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -11749,6 +21428,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -11916,6 +21605,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -12029,6 +21728,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -12095,6 +21804,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12118,6 +21828,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12127,7 +21838,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -12150,6 +21861,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12208,6 +21920,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12231,6 +21946,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12390,6 +22106,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12558,6 +22282,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12631,6 +22365,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12653,6 +22388,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -13071,6 +22807,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13167,6 +22924,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13175,6 +22933,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -13200,6 +22968,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13237,6 +23006,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -13360,6 +23130,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -13635,6 +23415,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -13760,6 +23550,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -13826,6 +23626,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -13849,6 +23650,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -13858,7 +23660,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -13869,19 +23671,26 @@ private constructor( return other is Price && allocationPrice == other.allocationPrice && + licenseAllocationPrice == other.licenseAllocationPrice && planPhaseOrder == other.planPhaseOrder && price == other.price && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(allocationPrice, planPhaseOrder, price, additionalProperties) + Objects.hash( + allocationPrice, + licenseAllocationPrice, + planPhaseOrder, + price, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Price{allocationPrice=$allocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" + "Price{allocationPrice=$allocationPrice, licenseAllocationPrice=$licenseAllocationPrice, planPhaseOrder=$planPhaseOrder, price=$price, additionalProperties=$additionalProperties}" } class Adjustment @@ -14151,6 +23960,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -14227,6 +24045,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = innerAdjustment.accept(new InnerAdjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentageDiscount != null -> @@ -14240,6 +24088,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): InnerAdjustment = apply { if (validated) { return@apply @@ -14532,6 +24390,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -14833,6 +24700,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PlanPhase = apply { if (validated) { return@apply @@ -14975,6 +24851,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DurationUnit = apply { if (validated) { return@apply @@ -15132,6 +25018,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply 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 9ecc22e0d..e6efea113 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 @@ -21,7 +21,8 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing plan. + * This endpoint can be used to update the `external_plan_id`, `description`, and `metadata` of an + * existing plan. * * Other fields on a plan are currently immutable. */ @@ -35,6 +36,14 @@ private constructor( fun otherExternalPlanId(): Optional = Optional.ofNullable(otherExternalPlanId) + /** + * An optional user-defined description of the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun description(): Optional = body.description() + /** * An optional user-defined ID for this plan resource, used throughout the system as an alias * for this Plan. Use this field to identify a plan by an existing identifier in your system. @@ -54,6 +63,13 @@ private constructor( */ fun metadata(): Optional = body.metadata() + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + /** * Returns the raw JSON value of [externalPlanId]. * @@ -120,11 +136,27 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] * - [externalPlanId] * - [metadata] */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** An optional user-defined description of the plan. */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in your @@ -312,6 +344,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val description: JsonField, private val externalPlanId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -319,13 +352,24 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), @JsonProperty("external_plan_id") @ExcludeMissing externalPlanId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - ) : this(externalPlanId, metadata, mutableMapOf()) + ) : this(description, externalPlanId, metadata, mutableMapOf()) + + /** + * An optional user-defined description of the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") /** * An optional user-defined ID for this plan resource, used throughout the system as an @@ -347,6 +391,15 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("metadata") + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + /** * Returns the raw JSON value of [externalPlanId]. * @@ -385,17 +438,36 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var description: JsonField = JsonMissing.of() private var externalPlanId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { + description = body.description externalPlanId = body.externalPlanId metadata = body.metadata additionalProperties = body.additionalProperties.toMutableMap() } + /** An optional user-defined description of the plan. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in @@ -462,16 +534,27 @@ private constructor( * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = Body(externalPlanId, metadata, additionalProperties.toMutableMap()) + fun build(): Body = + Body(description, externalPlanId, metadata, additionalProperties.toMutableMap()) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply } + description() externalPlanId() metadata().ifPresent { it.validate() } validated = true @@ -493,7 +576,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (externalPlanId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { @@ -502,19 +586,20 @@ private constructor( } return other is Body && + description == other.description && externalPlanId == other.externalPlanId && metadata == other.metadata && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(externalPlanId, metadata, additionalProperties) + Objects.hash(description, externalPlanId, metadata, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{externalPlanId=$externalPlanId, metadata=$metadata, additionalProperties=$additionalProperties}" + "Body{description=$description, externalPlanId=$externalPlanId, metadata=$metadata, additionalProperties=$additionalProperties}" } /** @@ -580,6 +665,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt index 604bf1938..7e4b87c8a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageResponse.kt @@ -184,6 +184,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt index f648c78e4..1a9cd3829 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt @@ -382,6 +382,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationCancelResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationCancelResponse.kt index 7fad38243..ed8ab0b8e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationCancelResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationCancelResponse.kt @@ -52,24 +52,34 @@ private constructor( ) : this(id, effectiveTime, planId, status, mutableMapOf()) /** + * Unique identifier for this plan version change. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") /** + * When the migration takes effect. Can be a specific date/time, or 'end_of_term' when scheduled + * to be at the end of the current billing period. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ fun effectiveTime(): Optional = effectiveTime.getOptional("effective_time") /** + * The ID of the plan being migrated. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun planId(): String = planId.getRequired("plan_id") /** + * Current status of the migration: 'not_started', 'in_progress', 'completed', 'action_needed', + * or 'canceled'. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -151,6 +161,7 @@ private constructor( additionalProperties = planMigrationCancelResponse.additionalProperties.toMutableMap() } + /** Unique identifier for this plan version change. */ fun id(id: String) = id(JsonField.of(id)) /** @@ -161,6 +172,10 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** + * When the migration takes effect. Can be a specific date/time, or 'end_of_term' when + * scheduled to be at the end of the current billing period. + */ fun effectiveTime(effectiveTime: EffectiveTime?) = effectiveTime(JsonField.ofNullable(effectiveTime)) @@ -191,6 +206,7 @@ private constructor( fun effectiveTime(unionMember2: EffectiveTime.UnionMember2) = effectiveTime(EffectiveTime.ofUnionMember2(unionMember2)) + /** The ID of the plan being migrated. */ fun planId(planId: String) = planId(JsonField.of(planId)) /** @@ -201,6 +217,10 @@ private constructor( */ fun planId(planId: JsonField) = apply { this.planId = planId } + /** + * Current status of the migration: 'not_started', 'in_progress', 'completed', + * 'action_needed', or 'canceled'. + */ fun status(status: Status) = status(JsonField.of(status)) /** @@ -257,6 +277,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanMigrationCancelResponse = apply { if (validated) { return@apply @@ -289,6 +317,10 @@ private constructor( (if (planId.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + /** + * When the migration takes effect. Can be a specific date/time, or 'end_of_term' when scheduled + * to be at the end of the current billing period. + */ @JsonDeserialize(using = EffectiveTime.Deserializer::class) @JsonSerialize(using = EffectiveTime.Serializer::class) class EffectiveTime @@ -319,6 +351,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = effectiveTime.accept(new EffectiveTime.Visitor>() { + * @Override + * public Optional visitLocalDate(LocalDate localDate) { + * return Optional.of(localDate.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { localDate != null -> visitor.visitLocalDate(localDate) @@ -329,6 +390,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EffectiveTime = apply { if (validated) { return@apply @@ -573,6 +643,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnionMember2 = apply { if (validated) { return@apply @@ -612,6 +692,10 @@ private constructor( } } + /** + * Current status of the migration: 'not_started', 'in_progress', 'completed', 'action_needed', + * or 'canceled'. + */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -716,6 +800,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationListPageResponse.kt index a0ae30036..2c64581b6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationListPageResponse.kt @@ -190,6 +190,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanMigrationListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationListResponse.kt index e48ebe94b..6ae1dfb40 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationListResponse.kt @@ -52,24 +52,34 @@ private constructor( ) : this(id, effectiveTime, planId, status, mutableMapOf()) /** + * Unique identifier for this plan version change. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") /** + * When the migration takes effect. Can be a specific date/time, or 'end_of_term' when scheduled + * to be at the end of the current billing period. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ fun effectiveTime(): Optional = effectiveTime.getOptional("effective_time") /** + * The ID of the plan being migrated. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun planId(): String = planId.getRequired("plan_id") /** + * Current status of the migration: 'not_started', 'in_progress', 'completed', 'action_needed', + * or 'canceled'. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -151,6 +161,7 @@ private constructor( additionalProperties = planMigrationListResponse.additionalProperties.toMutableMap() } + /** Unique identifier for this plan version change. */ fun id(id: String) = id(JsonField.of(id)) /** @@ -161,6 +172,10 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** + * When the migration takes effect. Can be a specific date/time, or 'end_of_term' when + * scheduled to be at the end of the current billing period. + */ fun effectiveTime(effectiveTime: EffectiveTime?) = effectiveTime(JsonField.ofNullable(effectiveTime)) @@ -191,6 +206,7 @@ private constructor( fun effectiveTime(unionMember2: EffectiveTime.UnionMember2) = effectiveTime(EffectiveTime.ofUnionMember2(unionMember2)) + /** The ID of the plan being migrated. */ fun planId(planId: String) = planId(JsonField.of(planId)) /** @@ -201,6 +217,10 @@ private constructor( */ fun planId(planId: JsonField) = apply { this.planId = planId } + /** + * Current status of the migration: 'not_started', 'in_progress', 'completed', + * 'action_needed', or 'canceled'. + */ fun status(status: Status) = status(JsonField.of(status)) /** @@ -257,6 +277,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanMigrationListResponse = apply { if (validated) { return@apply @@ -289,6 +317,10 @@ private constructor( (if (planId.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + /** + * When the migration takes effect. Can be a specific date/time, or 'end_of_term' when scheduled + * to be at the end of the current billing period. + */ @JsonDeserialize(using = EffectiveTime.Deserializer::class) @JsonSerialize(using = EffectiveTime.Serializer::class) class EffectiveTime @@ -319,6 +351,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = effectiveTime.accept(new EffectiveTime.Visitor>() { + * @Override + * public Optional visitLocalDate(LocalDate localDate) { + * return Optional.of(localDate.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { localDate != null -> visitor.visitLocalDate(localDate) @@ -329,6 +390,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EffectiveTime = apply { if (validated) { return@apply @@ -573,6 +643,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnionMember2 = apply { if (validated) { return@apply @@ -612,6 +692,10 @@ private constructor( } } + /** + * Current status of the migration: 'not_started', 'in_progress', 'completed', 'action_needed', + * or 'canceled'. + */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -716,6 +800,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponse.kt index 1098e0895..ba3b448a4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponse.kt @@ -52,24 +52,34 @@ private constructor( ) : this(id, effectiveTime, planId, status, mutableMapOf()) /** + * Unique identifier for this plan version change. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") /** + * When the migration takes effect. Can be a specific date/time, or 'end_of_term' when scheduled + * to be at the end of the current billing period. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server * responded with an unexpected value). */ fun effectiveTime(): Optional = effectiveTime.getOptional("effective_time") /** + * The ID of the plan being migrated. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ fun planId(): String = planId.getRequired("plan_id") /** + * Current status of the migration: 'not_started', 'in_progress', 'completed', 'action_needed', + * or 'canceled'. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ @@ -152,6 +162,7 @@ private constructor( additionalProperties = planMigrationRetrieveResponse.additionalProperties.toMutableMap() } + /** Unique identifier for this plan version change. */ fun id(id: String) = id(JsonField.of(id)) /** @@ -162,6 +173,10 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** + * When the migration takes effect. Can be a specific date/time, or 'end_of_term' when + * scheduled to be at the end of the current billing period. + */ fun effectiveTime(effectiveTime: EffectiveTime?) = effectiveTime(JsonField.ofNullable(effectiveTime)) @@ -192,6 +207,7 @@ private constructor( fun effectiveTime(unionMember2: EffectiveTime.UnionMember2) = effectiveTime(EffectiveTime.ofUnionMember2(unionMember2)) + /** The ID of the plan being migrated. */ fun planId(planId: String) = planId(JsonField.of(planId)) /** @@ -202,6 +218,10 @@ private constructor( */ fun planId(planId: JsonField) = apply { this.planId = planId } + /** + * Current status of the migration: 'not_started', 'in_progress', 'completed', + * 'action_needed', or 'canceled'. + */ fun status(status: Status) = status(JsonField.of(status)) /** @@ -258,6 +278,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanMigrationRetrieveResponse = apply { if (validated) { return@apply @@ -290,6 +318,10 @@ private constructor( (if (planId.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + /** + * When the migration takes effect. Can be a specific date/time, or 'end_of_term' when scheduled + * to be at the end of the current billing period. + */ @JsonDeserialize(using = EffectiveTime.Deserializer::class) @JsonSerialize(using = EffectiveTime.Serializer::class) class EffectiveTime @@ -320,6 +352,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = effectiveTime.accept(new EffectiveTime.Visitor>() { + * @Override + * public Optional visitLocalDate(LocalDate localDate) { + * return Optional.of(localDate.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { localDate != null -> visitor.visitLocalDate(localDate) @@ -330,6 +391,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EffectiveTime = apply { if (validated) { return@apply @@ -574,6 +644,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnionMember2 = apply { if (validated) { return@apply @@ -613,6 +693,10 @@ private constructor( } } + /** + * Current status of the migration: 'not_started', 'in_progress', 'completed', 'action_needed', + * or 'canceled'. + */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -717,6 +801,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt index 8667506bc..abee5a4fa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseAmountDiscountAdjustment.kt @@ -524,6 +524,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanPhaseAmountDiscountAdjustment = apply { if (validated) { return@apply @@ -650,6 +658,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -890,6 +907,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1029,6 +1055,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1158,6 +1194,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt index 3af5c683f..9e4a96a4c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMaximumAdjustment.kt @@ -521,6 +521,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanPhaseMaximumAdjustment = apply { if (validated) { return@apply @@ -647,6 +655,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -887,6 +904,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1026,6 +1052,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1155,6 +1191,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt index 377055d4b..ae1f62c31 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseMinimumAdjustment.kt @@ -555,6 +555,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanPhaseMinimumAdjustment = apply { if (validated) { return@apply @@ -683,6 +691,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -923,6 +940,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1062,6 +1088,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1191,6 +1227,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt index f4e48bb3a..4bc97494d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhasePercentageDiscountAdjustment.kt @@ -527,6 +527,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanPhasePercentageDiscountAdjustment = apply { if (validated) { return@apply @@ -653,6 +661,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -893,6 +910,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1032,6 +1058,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1161,6 +1197,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt index 7e51f3f0e..e4f06c7bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanPhaseUsageDiscountAdjustment.kt @@ -524,6 +524,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanPhaseUsageDiscountAdjustment = apply { if (validated) { return@apply @@ -650,6 +658,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AdjustmentType = apply { if (validated) { return@apply @@ -890,6 +907,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -1029,6 +1055,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1158,6 +1194,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply 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 f3fce53fd..bc1c6567f 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 @@ -21,7 +21,8 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing plan. + * This endpoint can be used to update the `external_plan_id`, `description`, and `metadata` of an + * existing plan. * * Other fields on a plan are currently immutable. */ @@ -35,6 +36,14 @@ private constructor( fun planId(): Optional = Optional.ofNullable(planId) + /** + * An optional user-defined description of the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun description(): Optional = body.description() + /** * An optional user-defined ID for this plan resource, used throughout the system as an alias * for this Plan. Use this field to identify a plan by an existing identifier in your system. @@ -54,6 +63,13 @@ private constructor( */ fun metadata(): Optional = body.metadata() + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + /** * Returns the raw JSON value of [externalPlanId]. * @@ -112,11 +128,27 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] * - [externalPlanId] * - [metadata] */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** An optional user-defined description of the plan. */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in your @@ -304,6 +336,7 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val description: JsonField, private val externalPlanId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -311,13 +344,24 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), @JsonProperty("external_plan_id") @ExcludeMissing externalPlanId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - ) : this(externalPlanId, metadata, mutableMapOf()) + ) : this(description, externalPlanId, metadata, mutableMapOf()) + + /** + * An optional user-defined description of the plan. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") /** * An optional user-defined ID for this plan resource, used throughout the system as an @@ -339,6 +383,15 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("metadata") + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + /** * Returns the raw JSON value of [externalPlanId]. * @@ -377,17 +430,36 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var description: JsonField = JsonMissing.of() private var externalPlanId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { + description = body.description externalPlanId = body.externalPlanId metadata = body.metadata additionalProperties = body.additionalProperties.toMutableMap() } + /** An optional user-defined description of the plan. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in @@ -454,16 +526,27 @@ private constructor( * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = Body(externalPlanId, metadata, additionalProperties.toMutableMap()) + fun build(): Body = + Body(description, externalPlanId, metadata, additionalProperties.toMutableMap()) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply } + description() externalPlanId() metadata().ifPresent { it.validate() } validated = true @@ -485,7 +568,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (externalPlanId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (externalPlanId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { @@ -494,19 +578,20 @@ private constructor( } return other is Body && + description == other.description && externalPlanId == other.externalPlanId && metadata == other.metadata && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(externalPlanId, metadata, additionalProperties) + Objects.hash(description, externalPlanId, metadata, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{externalPlanId=$externalPlanId, metadata=$metadata, additionalProperties=$additionalProperties}" + "Body{description=$description, externalPlanId=$externalPlanId, metadata=$metadata, additionalProperties=$additionalProperties}" } /** @@ -572,6 +657,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt index cf2212c1f..ac9820295 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersion.kt @@ -368,6 +368,13 @@ private constructor( fun addPrice(matrixWithAllocation: Price.MatrixWithAllocation) = addPrice(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [addPrice] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun addPrice(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + addPrice(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** Alias for calling [addPrice] with `Price.ofTieredWithProration(tieredWithProration)`. */ fun addPrice(tieredWithProration: Price.TieredWithProration) = addPrice(Price.ofTieredWithProration(tieredWithProration)) @@ -450,6 +457,16 @@ private constructor( fun addPrice(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = addPrice(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [addPrice] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun addPrice(dailyCreditAllowance: Price.DailyCreditAllowance) = + addPrice(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [addPrice] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun addPrice(meteredAllowance: Price.MeteredAllowance) = + addPrice(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [addPrice] with `Price.ofMinimumComposite(minimumComposite)`. */ fun addPrice(minimumComposite: Price.MinimumComposite) = addPrice(Price.ofMinimumComposite(minimumComposite)) @@ -518,6 +535,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanVersion = apply { if (validated) { return@apply @@ -602,6 +627,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitUsageDiscount(PlanPhaseUsageDiscountAdjustment usageDiscount) { + * return Optional.of(usageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) @@ -614,6 +668,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt index c4c0bdbb9..4b4efce20 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanVersionPhase.kt @@ -318,6 +318,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PlanVersionPhase = apply { if (validated) { return@apply @@ -461,6 +469,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DurationUnit = apply { if (validated) { return@apply 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 efc13af59..8acd77e18 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 @@ -62,6 +62,7 @@ private constructor( private val packageWithAllocation: PackageWithAllocation? = null, private val unitWithPercent: UnitWithPercent? = null, private val matrixWithAllocation: MatrixWithAllocation? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, private val tieredWithProration: TieredWithProration? = null, private val unitWithProration: UnitWithProration? = null, private val groupedAllocation: GroupedAllocation? = null, @@ -76,6 +77,8 @@ private constructor( private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, private val minimumComposite: MinimumComposite? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -114,6 +117,9 @@ private constructor( fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -153,6 +159,11 @@ private constructor( fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = Optional.ofNullable(meteredAllowance) + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) fun percent(): Optional = Optional.ofNullable(percent) @@ -187,6 +198,8 @@ private constructor( fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null @@ -215,6 +228,10 @@ private constructor( fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + fun isMinimumComposite(): Boolean = minimumComposite != null fun isPercent(): Boolean = percent != null @@ -253,6 +270,9 @@ private constructor( fun asMatrixWithAllocation(): MatrixWithAllocation = matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") @@ -292,6 +312,11 @@ private constructor( fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = meteredAllowance.getOrThrow("meteredAllowance") + fun asMinimumComposite(): MinimumComposite = minimumComposite.getOrThrow("minimumComposite") fun asPercent(): Percent = percent.getOrThrow("percent") @@ -300,6 +325,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(UnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and the + * current variant is unknown. + */ fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) @@ -318,6 +372,8 @@ private constructor( visitor.visitPackageWithAllocation(packageWithAllocation) unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) @@ -341,6 +397,8 @@ private constructor( visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) cumulativeGroupedAllocation != null -> visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -349,6 +407,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Price = apply { if (validated) { return@apply @@ -416,6 +482,12 @@ private constructor( matrixWithAllocation.validate() } + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + override fun visitTieredWithProration(tieredWithProration: TieredWithProration) { tieredWithProration.validate() } @@ -490,6 +562,14 @@ private constructor( cumulativeGroupedAllocation.validate() } + override fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + override fun visitMinimumComposite(minimumComposite: MinimumComposite) { minimumComposite.validate() } @@ -562,6 +642,10 @@ private constructor( override fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = matrixWithAllocation.validity() + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + override fun visitTieredWithProration(tieredWithProration: TieredWithProration) = tieredWithProration.validity() @@ -613,6 +697,12 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() + override fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + override fun visitMinimumComposite(minimumComposite: MinimumComposite) = minimumComposite.validity() @@ -644,6 +734,7 @@ private constructor( packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && @@ -658,6 +749,8 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && minimumComposite == other.minimumComposite && percent == other.percent && eventOutput == other.eventOutput @@ -679,6 +772,7 @@ private constructor( packageWithAllocation, unitWithPercent, matrixWithAllocation, + matrixWithThresholdDiscounts, tieredWithProration, unitWithProration, groupedAllocation, @@ -693,6 +787,8 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, minimumComposite, percent, eventOutput, @@ -715,6 +811,8 @@ private constructor( packageWithAllocation != null -> "Price{packageWithAllocation=$packageWithAllocation}" unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" @@ -735,6 +833,8 @@ private constructor( cumulativeGroupedBulk != null -> "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -788,6 +888,11 @@ private constructor( fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + @JvmStatic fun ofTieredWithProration(tieredWithProration: TieredWithProration) = Price(tieredWithProration = tieredWithProration) @@ -848,6 +953,14 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + @JvmStatic fun ofMinimumComposite(minimumComposite: MinimumComposite) = Price(minimumComposite = minimumComposite) @@ -888,6 +1001,10 @@ private constructor( fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T fun visitUnitWithProration(unitWithProration: UnitWithProration): T @@ -926,6 +1043,10 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + fun visitMinimumComposite(minimumComposite: MinimumComposite): T fun visitPercent(percent: Percent): T @@ -1023,6 +1144,11 @@ private constructor( Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } + "matrix_with_threshold_discounts" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } "tiered_with_proration" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(tieredWithProration = it, _json = json) @@ -1093,6 +1219,16 @@ private constructor( ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } ?: Price(_json = json) } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(dailyCreditAllowance = it, _json = json) + } ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } "minimum_composite" -> { return tryDeserialize(node, jacksonTypeRef())?.let { Price(minimumComposite = it, _json = json) @@ -1140,6 +1276,8 @@ private constructor( value.unitWithPercent != null -> generator.writeObject(value.unitWithPercent) value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> generator.writeObject(value.unitWithProration) @@ -1165,6 +1303,9 @@ private constructor( generator.writeObject(value.cumulativeGroupedBulk) value.cumulativeGroupedAllocation != null -> generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> generator.writeObject(value.meteredAllowance) value.minimumComposite != null -> generator.writeObject(value.minimumComposite) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -1191,6 +1332,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -1205,6 +1347,7 @@ private constructor( private val replacesPriceId: JsonField, private val unitConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -1248,6 +1391,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -1281,6 +1427,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -1296,6 +1445,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -1310,6 +1460,7 @@ private constructor( replacesPriceId, unitConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -1404,6 +1555,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1511,6 +1669,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -1641,6 +1808,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -1764,6 +1941,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1797,6 +1983,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -1831,6 +2018,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -1846,6 +2034,7 @@ private constructor( private var unitConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1864,6 +2053,7 @@ private constructor( discount = unitPrice.discount externalPriceId = unitPrice.externalPriceId fixedPriceQuantity = unitPrice.fixedPriceQuantity + invoiceGroupingKey = unitPrice.invoiceGroupingKey invoicingCycleConfiguration = unitPrice.invoicingCycleConfiguration item = unitPrice.item maximum = unitPrice.maximum @@ -1878,6 +2068,7 @@ private constructor( replacesPriceId = unitPrice.replacesPriceId unitConfig = unitPrice.unitConfig dimensionalPriceConfiguration = unitPrice.dimensionalPriceConfiguration + licenseType = unitPrice.licenseType additionalProperties = unitPrice.additionalProperties.toMutableMap() } @@ -2256,6 +2447,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -2506,6 +2718,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2546,6 +2781,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -2580,6 +2816,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -2594,12 +2831,22 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("unitConfig", unitConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitPrice = apply { if (validated) { return@apply @@ -2619,6 +2866,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -2637,6 +2885,7 @@ private constructor( replacesPriceId() unitConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -2671,6 +2920,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -2684,7 +2934,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2777,6 +3028,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -2929,6 +3190,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -3178,6 +3449,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -3321,6 +3602,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -3453,6 +3744,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -3579,6 +3880,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -3717,6 +4028,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -3755,6 +4076,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3775,6 +4364,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -3789,6 +4379,7 @@ private constructor( replacesPriceId == other.replacesPriceId && unitConfig == other.unitConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -3808,6 +4399,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -3822,6 +4414,7 @@ private constructor( replacesPriceId, unitConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -3829,7 +4422,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Tiered @@ -3849,6 +4442,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -3863,6 +4457,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -3906,6 +4501,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -3939,6 +4537,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -3954,6 +4555,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -3968,6 +4570,7 @@ private constructor( replacesPriceId, tieredConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -4062,6 +4665,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -4169,6 +4779,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -4299,6 +4918,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -4423,6 +5052,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4456,6 +5094,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -4490,6 +5129,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -4505,6 +5145,7 @@ private constructor( private var tieredConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4523,6 +5164,7 @@ private constructor( discount = tiered.discount externalPriceId = tiered.externalPriceId fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey invoicingCycleConfiguration = tiered.invoicingCycleConfiguration item = tiered.item maximum = tiered.maximum @@ -4537,6 +5179,7 @@ private constructor( replacesPriceId = tiered.replacesPriceId tieredConfig = tiered.tieredConfig dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + licenseType = tiered.licenseType additionalProperties = tiered.additionalProperties.toMutableMap() } @@ -4915,6 +5558,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -5165,6 +5829,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5205,6 +5892,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -5239,6 +5927,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -5253,12 +5942,22 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredConfig", tieredConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Tiered = apply { if (validated) { return@apply @@ -5278,6 +5977,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -5296,6 +5996,7 @@ private constructor( replacesPriceId() tieredConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -5330,6 +6031,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -5343,7 +6045,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5436,6 +6139,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -5588,6 +6301,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -5837,6 +6560,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -5980,6 +6713,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -6112,6 +6855,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -6238,6 +6991,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -6376,6 +7139,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -6414,6 +7187,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -6434,6 +7475,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -6448,6 +7490,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -6467,6 +7510,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -6481,6 +7525,7 @@ private constructor( replacesPriceId, tieredConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -6488,7 +7533,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Bulk @@ -6509,6 +7554,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -6522,6 +7568,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -6568,6 +7615,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -6598,6 +7648,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -6614,6 +7667,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -6627,6 +7681,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -6729,6 +7784,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -6828,6 +7890,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -6967,6 +8038,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -7081,6 +8162,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -7115,6 +8205,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -7149,6 +8240,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -7163,6 +8255,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7182,6 +8275,7 @@ private constructor( discount = bulk.discount externalPriceId = bulk.externalPriceId fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey invoicingCycleConfiguration = bulk.invoicingCycleConfiguration item = bulk.item maximum = bulk.maximum @@ -7195,6 +8289,7 @@ private constructor( priceType = bulk.priceType replacesPriceId = bulk.replacesPriceId dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + licenseType = bulk.licenseType additionalProperties = bulk.additionalProperties.toMutableMap() } @@ -7587,6 +8682,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -7823,6 +8939,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -7864,6 +9003,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -7898,6 +9038,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -7911,12 +9052,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Bulk = apply { if (validated) { return@apply @@ -7937,6 +9088,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -7954,6 +9106,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -7989,6 +9142,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -8001,7 +9155,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8094,6 +9249,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -8246,6 +9411,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -8495,6 +9670,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -8638,6 +9823,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -8770,6 +9965,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -8896,6 +10101,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -9034,6 +10249,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -9072,6 +10297,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -9093,6 +10586,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -9106,6 +10600,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -9126,6 +10621,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -9139,6 +10635,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -9146,7 +10643,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkConfig=$bulkConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class BulkWithFilters @@ -9167,6 +10664,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -9180,6 +10678,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -9226,6 +10725,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -9256,6 +10758,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -9272,6 +10777,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -9285,6 +10791,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -9388,6 +10895,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -9487,6 +11001,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -9627,6 +11150,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -9741,6 +11274,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -9775,6 +11317,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -9809,6 +11352,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -9823,6 +11367,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9843,6 +11388,7 @@ private constructor( discount = bulkWithFilters.discount externalPriceId = bulkWithFilters.externalPriceId fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration item = bulkWithFilters.item maximum = bulkWithFilters.maximum @@ -9856,6 +11402,7 @@ private constructor( priceType = bulkWithFilters.priceType replacesPriceId = bulkWithFilters.replacesPriceId dimensionalPriceConfiguration = bulkWithFilters.dimensionalPriceConfiguration + licenseType = bulkWithFilters.licenseType additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -10250,6 +11797,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -10486,6 +12054,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -10527,6 +12118,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -10561,6 +12153,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -10574,12 +12167,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BulkWithFilters = apply { if (validated) { return@apply @@ -10600,6 +12203,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -10617,6 +12221,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -10652,6 +12257,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -10664,7 +12270,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -10757,6 +12364,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -10986,6 +12603,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply @@ -11186,6 +12813,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -11412,6 +13049,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -11595,6 +13242,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -11844,6 +13501,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -11987,6 +13654,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -12119,6 +13796,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -12245,6 +13932,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -12383,6 +14080,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -12421,6 +14128,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -12442,6 +14417,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -12455,6 +14431,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -12475,6 +14452,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -12488,6 +14466,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -12495,7 +14474,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkWithFilters{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Package @@ -12515,6 +14494,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -12529,6 +14509,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -12572,6 +14553,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -12605,6 +14589,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -12620,6 +14607,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -12634,6 +14622,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -12728,6 +14717,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -12835,6 +14831,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -12965,6 +14970,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -13089,6 +15104,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -13122,6 +15146,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -13156,6 +15181,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -13171,6 +15197,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13189,6 +15216,7 @@ private constructor( discount = package_.discount externalPriceId = package_.externalPriceId fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey invoicingCycleConfiguration = package_.invoicingCycleConfiguration item = package_.item maximum = package_.maximum @@ -13203,6 +15231,7 @@ private constructor( priceType = package_.priceType replacesPriceId = package_.replacesPriceId dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + licenseType = package_.licenseType additionalProperties = package_.additionalProperties.toMutableMap() } @@ -13581,6 +15610,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -13832,6 +15882,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -13872,6 +15945,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -13906,6 +15980,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -13920,12 +15995,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Package = apply { if (validated) { return@apply @@ -13945,6 +16030,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -13963,6 +16049,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -13997,6 +16084,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -14010,7 +16098,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -14103,6 +16192,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -14255,6 +16354,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -14504,6 +16613,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -14647,6 +16766,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -14779,6 +16908,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -14905,6 +17044,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -15043,6 +17192,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -15081,6 +17240,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -15101,6 +17528,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -15115,6 +17543,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -15134,6 +17563,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -15148,6 +17578,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -15155,7 +17586,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Matrix @@ -15175,6 +17606,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val matrixConfig: JsonField, @@ -15189,6 +17621,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -15232,6 +17665,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -15265,6 +17701,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -15280,6 +17719,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixConfig, @@ -15294,6 +17734,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -15388,6 +17829,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -15495,6 +17943,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -15625,6 +18082,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -15749,6 +18216,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -15782,6 +18258,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixConfig() @@ -15816,6 +18293,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var matrixConfig: JsonField? = null @@ -15831,6 +18309,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15849,6 +18328,7 @@ private constructor( discount = matrix.discount externalPriceId = matrix.externalPriceId fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey invoicingCycleConfiguration = matrix.invoicingCycleConfiguration item = matrix.item matrixConfig = matrix.matrixConfig @@ -15863,6 +18343,7 @@ private constructor( priceType = matrix.priceType replacesPriceId = matrix.replacesPriceId dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + licenseType = matrix.licenseType additionalProperties = matrix.additionalProperties.toMutableMap() } @@ -16241,6 +18722,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -16491,6 +18993,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -16531,6 +19056,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixConfig() @@ -16565,6 +19091,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("matrixConfig", matrixConfig), @@ -16579,12 +19106,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Matrix = apply { if (validated) { return@apply @@ -16604,6 +19141,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() matrixConfig().validate() @@ -16622,6 +19160,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -16656,6 +19195,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -16669,7 +19209,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -16762,6 +19303,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -16914,6 +19465,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -17163,6 +19724,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -17306,6 +19877,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -17438,6 +20019,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -17564,6 +20155,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -17702,6 +20303,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -17740,6 +20351,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -17760,6 +20639,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixConfig == other.matrixConfig && @@ -17774,6 +20654,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -17793,6 +20674,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixConfig, @@ -17807,6 +20689,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -17814,7 +20697,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class ThresholdTotalAmount @@ -17834,6 +20717,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -17848,6 +20732,7 @@ private constructor( private val replacesPriceId: JsonField, private val thresholdTotalAmountConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -17891,6 +20776,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -17924,6 +20812,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -17939,6 +20830,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -17953,6 +20845,7 @@ private constructor( replacesPriceId, thresholdTotalAmountConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -18047,6 +20940,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -18155,6 +21055,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -18285,6 +21194,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -18410,6 +21329,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -18443,6 +21371,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -18477,6 +21406,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -18492,6 +21422,7 @@ private constructor( private var thresholdTotalAmountConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18511,6 +21442,7 @@ private constructor( discount = thresholdTotalAmount.discount externalPriceId = thresholdTotalAmount.externalPriceId fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey invoicingCycleConfiguration = thresholdTotalAmount.invoicingCycleConfiguration item = thresholdTotalAmount.item maximum = thresholdTotalAmount.maximum @@ -18525,6 +21457,7 @@ private constructor( replacesPriceId = thresholdTotalAmount.replacesPriceId thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig dimensionalPriceConfiguration = thresholdTotalAmount.dimensionalPriceConfiguration + licenseType = thresholdTotalAmount.licenseType additionalProperties = thresholdTotalAmount.additionalProperties.toMutableMap() } @@ -18903,6 +21836,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -19154,6 +22108,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -19194,6 +22171,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -19228,6 +22206,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -19242,12 +22221,22 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply @@ -19267,6 +22256,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -19285,6 +22275,7 @@ private constructor( replacesPriceId() thresholdTotalAmountConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -19319,6 +22310,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -19332,7 +22324,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -19425,6 +22418,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -19577,6 +22580,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -19826,6 +22839,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -19969,6 +22992,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -20101,6 +23134,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -20227,6 +23270,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -20365,6 +23418,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -20598,6 +23661,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ThresholdTotalAmountConfig = apply { if (validated) { return@apply @@ -20794,6 +23867,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ConsumptionTable = apply { if (validated) { return@apply @@ -20865,6 +23948,274 @@ private constructor( "ThresholdTotalAmountConfig{consumptionTable=$consumptionTable, prorate=$prorate, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -20885,6 +24236,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -20899,6 +24251,7 @@ private constructor( replacesPriceId == other.replacesPriceId && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -20918,6 +24271,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -20932,6 +24286,7 @@ private constructor( replacesPriceId, thresholdTotalAmountConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -20939,7 +24294,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredPackage @@ -20959,6 +24314,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -20973,6 +24329,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredPackageConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -21016,6 +24373,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -21049,6 +24409,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -21064,6 +24427,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -21078,6 +24442,7 @@ private constructor( replacesPriceId, tieredPackageConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -21172,6 +24537,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -21280,6 +24652,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -21410,6 +24791,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -21534,6 +24925,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -21567,6 +24967,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -21601,6 +25002,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -21616,6 +25018,7 @@ private constructor( private var tieredPackageConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21635,6 +25038,7 @@ private constructor( discount = tieredPackage.discount externalPriceId = tieredPackage.externalPriceId fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration item = tieredPackage.item maximum = tieredPackage.maximum @@ -21649,6 +25053,7 @@ private constructor( replacesPriceId = tieredPackage.replacesPriceId tieredPackageConfig = tieredPackage.tieredPackageConfig dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + licenseType = tieredPackage.licenseType additionalProperties = tieredPackage.additionalProperties.toMutableMap() } @@ -22027,6 +25432,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -22278,6 +25704,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -22318,6 +25767,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -22352,6 +25802,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -22366,12 +25817,22 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredPackageConfig", tieredPackageConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackage = apply { if (validated) { return@apply @@ -22391,6 +25852,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -22409,6 +25871,7 @@ private constructor( replacesPriceId() tieredPackageConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -22443,6 +25906,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -22456,7 +25920,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -22549,6 +26014,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -22701,6 +26176,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -22950,6 +26435,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -23093,6 +26588,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -23225,6 +26730,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -23351,6 +26866,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -23489,6 +27014,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -23711,6 +27246,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackageConfig = apply { if (validated) { return@apply @@ -23906,6 +27451,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -23977,6 +27532,274 @@ private constructor( "TieredPackageConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -23997,6 +27820,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -24011,6 +27835,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -24030,6 +27855,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -24044,6 +27870,7 @@ private constructor( replacesPriceId, tieredPackageConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -24051,7 +27878,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredWithMinimum @@ -24071,6 +27898,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -24085,6 +27913,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -24128,6 +27957,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -24161,6 +27993,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -24176,6 +28011,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -24190,6 +28026,7 @@ private constructor( replacesPriceId, tieredWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -24284,6 +28121,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -24392,6 +28236,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -24522,6 +28375,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -24646,6 +28509,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -24679,6 +28551,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -24713,6 +28586,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -24728,6 +28602,7 @@ private constructor( private var tieredWithMinimumConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24747,6 +28622,7 @@ private constructor( discount = tieredWithMinimum.discount externalPriceId = tieredWithMinimum.externalPriceId fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration item = tieredWithMinimum.item maximum = tieredWithMinimum.maximum @@ -24761,6 +28637,7 @@ private constructor( replacesPriceId = tieredWithMinimum.replacesPriceId tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig dimensionalPriceConfiguration = tieredWithMinimum.dimensionalPriceConfiguration + licenseType = tieredWithMinimum.licenseType additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } @@ -25139,6 +29016,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -25390,6 +29288,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -25430,6 +29351,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -25464,6 +29386,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -25478,12 +29401,22 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredWithMinimum = apply { if (validated) { return@apply @@ -25503,6 +29436,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -25521,6 +29455,7 @@ private constructor( replacesPriceId() tieredWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -25555,6 +29490,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -25568,7 +29504,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -25661,6 +29598,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -25813,6 +29760,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -26062,6 +30019,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -26205,6 +30172,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -26337,6 +30314,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -26463,6 +30450,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -26601,6 +30598,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -26859,6 +30866,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredWithMinimumConfig = apply { if (validated) { return@apply @@ -27098,6 +31115,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -27173,6 +31200,274 @@ private constructor( "TieredWithMinimumConfig{tiers=$tiers, hideZeroAmountTiers=$hideZeroAmountTiers, prorate=$prorate, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -27193,6 +31488,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -27207,6 +31503,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -27226,6 +31523,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -27240,6 +31538,7 @@ private constructor( replacesPriceId, tieredWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -27247,7 +31546,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class GroupedTiered @@ -27268,6 +31567,7 @@ private constructor( private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, private val groupedTieredConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -27281,6 +31581,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -27327,6 +31628,9 @@ private constructor( @JsonProperty("grouped_tiered_config") @ExcludeMissing groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -27357,6 +31661,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -27373,6 +31680,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedTieredConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -27386,6 +31694,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -27489,6 +31798,13 @@ private constructor( fun groupedTieredConfig(): GroupedTieredConfig = groupedTieredConfig.getRequired("grouped_tiered_config") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -27588,6 +31904,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -27728,6 +32053,16 @@ private constructor( @ExcludeMissing fun _groupedTieredConfig(): JsonField = groupedTieredConfig + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -27842,6 +32177,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -27876,6 +32220,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedTieredConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -27910,6 +32255,7 @@ private constructor( private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null private var groupedTieredConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -27924,6 +32270,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -27944,6 +32291,7 @@ private constructor( externalPriceId = groupedTiered.externalPriceId fixedPriceQuantity = groupedTiered.fixedPriceQuantity groupedTieredConfig = groupedTiered.groupedTieredConfig + invoiceGroupingKey = groupedTiered.invoiceGroupingKey invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration item = groupedTiered.item maximum = groupedTiered.maximum @@ -27957,6 +32305,7 @@ private constructor( priceType = groupedTiered.priceType replacesPriceId = groupedTiered.replacesPriceId dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + licenseType = groupedTiered.licenseType additionalProperties = groupedTiered.additionalProperties.toMutableMap() } @@ -28350,6 +32699,27 @@ private constructor( this.groupedTieredConfig = groupedTieredConfig } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -28586,6 +32956,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -28627,6 +33020,7 @@ private constructor( * .externalPriceId() * .fixedPriceQuantity() * .groupedTieredConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -28661,6 +33055,7 @@ private constructor( checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -28674,12 +33069,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedTiered = apply { if (validated) { return@apply @@ -28700,6 +33105,7 @@ private constructor( externalPriceId() fixedPriceQuantity() groupedTieredConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -28717,6 +33123,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -28752,6 +33159,7 @@ private constructor( (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -28764,7 +33172,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -28857,6 +33266,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -29009,6 +33428,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -29258,6 +33687,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -29401,6 +33840,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -29533,6 +33982,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -29775,6 +34234,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedTieredConfig = apply { if (validated) { return@apply @@ -29972,6 +34441,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -30109,6 +34588,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -30247,6 +34736,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -30285,6 +34784,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30306,6 +35073,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredConfig == other.groupedTieredConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -30319,6 +35087,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -30339,6 +35108,7 @@ private constructor( externalPriceId, fixedPriceQuantity, groupedTieredConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -30352,6 +35122,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -30359,7 +35130,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class TieredPackageWithMinimum @@ -30379,6 +35150,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -30393,6 +35165,7 @@ private constructor( private val replacesPriceId: JsonField, private val tieredPackageWithMinimumConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -30436,6 +35209,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -30470,6 +35246,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -30485,6 +35264,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -30499,6 +35279,7 @@ private constructor( replacesPriceId, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -30593,6 +35374,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -30701,6 +35489,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -30831,6 +35628,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -30956,6 +35763,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -30989,6 +35805,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -31023,6 +35840,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -31039,6 +35857,7 @@ private constructor( null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -31058,6 +35877,7 @@ private constructor( discount = tieredPackageWithMinimum.discount externalPriceId = tieredPackageWithMinimum.externalPriceId fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey invoicingCycleConfiguration = tieredPackageWithMinimum.invoicingCycleConfiguration item = tieredPackageWithMinimum.item maximum = tieredPackageWithMinimum.maximum @@ -31074,6 +35894,7 @@ private constructor( tieredPackageWithMinimum.tieredPackageWithMinimumConfig dimensionalPriceConfiguration = tieredPackageWithMinimum.dimensionalPriceConfiguration + licenseType = tieredPackageWithMinimum.licenseType additionalProperties = tieredPackageWithMinimum.additionalProperties.toMutableMap() } @@ -31452,6 +36273,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -31704,6 +36546,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -31744,6 +36609,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -31778,6 +36644,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -31792,12 +36659,22 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackageWithMinimum = apply { if (validated) { return@apply @@ -31817,6 +36694,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -31835,6 +36713,7 @@ private constructor( replacesPriceId() tieredPackageWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -31869,6 +36748,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -31884,7 +36764,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -31977,6 +36858,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -32129,6 +37020,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -32378,6 +37279,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -32521,6 +37432,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -32653,6 +37574,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -32779,6 +37710,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -32917,6 +37858,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -33138,6 +38089,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TieredPackageWithMinimumConfig = apply { if (validated) { return@apply @@ -33370,6 +38331,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -33444,6 +38415,274 @@ private constructor( "TieredPackageWithMinimumConfig{packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -33464,6 +38703,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -33478,6 +38718,7 @@ private constructor( replacesPriceId == other.replacesPriceId && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -33497,6 +38738,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -33511,6 +38753,7 @@ private constructor( replacesPriceId, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -33518,7 +38761,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class PackageWithAllocation @@ -33538,6 +38781,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -33552,6 +38796,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -33595,6 +38840,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -33628,6 +38876,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -33643,6 +38894,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -33657,6 +38909,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -33751,6 +39004,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -33859,6 +39119,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -33989,6 +39258,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -34114,6 +39393,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -34147,6 +39435,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -34181,6 +39470,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -34196,6 +39486,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -34215,6 +39506,7 @@ private constructor( discount = packageWithAllocation.discount externalPriceId = packageWithAllocation.externalPriceId fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = packageWithAllocation.invoicingCycleConfiguration item = packageWithAllocation.item maximum = packageWithAllocation.maximum @@ -34229,6 +39521,7 @@ private constructor( priceType = packageWithAllocation.priceType replacesPriceId = packageWithAllocation.replacesPriceId dimensionalPriceConfiguration = packageWithAllocation.dimensionalPriceConfiguration + licenseType = packageWithAllocation.licenseType additionalProperties = packageWithAllocation.additionalProperties.toMutableMap() } @@ -34607,6 +39900,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -34859,6 +40173,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -34899,6 +40236,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -34933,6 +40271,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -34947,12 +40286,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PackageWithAllocation = apply { if (validated) { return@apply @@ -34972,6 +40321,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -34990,6 +40340,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -35024,6 +40375,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -35037,7 +40389,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -35130,6 +40483,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -35282,6 +40645,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -35531,6 +40904,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -35674,6 +41057,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -35806,6 +41199,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -35932,6 +41335,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -36180,6 +41593,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PackageWithAllocationConfig = apply { if (validated) { return@apply @@ -36330,6 +41753,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -36368,6 +41801,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -36388,6 +42089,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -36402,6 +42104,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -36421,6 +42124,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -36435,6 +42139,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -36442,7 +42147,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class UnitWithPercent @@ -36462,6 +42167,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -36476,6 +42182,7 @@ private constructor( private val replacesPriceId: JsonField, private val unitWithPercentConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -36519,6 +42226,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -36552,6 +42262,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -36567,6 +42280,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -36581,6 +42295,7 @@ private constructor( replacesPriceId, unitWithPercentConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -36675,6 +42390,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -36783,6 +42505,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -36913,6 +42644,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -37037,6 +42778,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -37070,6 +42820,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -37104,6 +42855,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -37119,6 +42871,7 @@ private constructor( private var unitWithPercentConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -37138,6 +42891,7 @@ private constructor( discount = unitWithPercent.discount externalPriceId = unitWithPercent.externalPriceId fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration item = unitWithPercent.item maximum = unitWithPercent.maximum @@ -37152,6 +42906,7 @@ private constructor( replacesPriceId = unitWithPercent.replacesPriceId unitWithPercentConfig = unitWithPercent.unitWithPercentConfig dimensionalPriceConfiguration = unitWithPercent.dimensionalPriceConfiguration + licenseType = unitWithPercent.licenseType additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } @@ -37530,6 +43285,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -37782,6 +43558,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -37822,6 +43621,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -37856,6 +43656,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -37870,12 +43671,22 @@ private constructor( checkRequired("replacesPriceId", replacesPriceId), checkRequired("unitWithPercentConfig", unitWithPercentConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitWithPercent = apply { if (validated) { return@apply @@ -37895,6 +43706,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -37913,6 +43725,7 @@ private constructor( replacesPriceId() unitWithPercentConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -37947,6 +43760,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -37960,7 +43774,8 @@ private constructor( (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -38053,6 +43868,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -38205,6 +44030,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -38454,6 +44289,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -38597,6 +44442,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -38729,6 +44584,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -38855,6 +44720,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -38993,6 +44868,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -39197,6 +45082,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnitWithPercentConfig = apply { if (validated) { return@apply @@ -39247,6 +45142,274 @@ private constructor( "UnitWithPercentConfig{percent=$percent, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -39267,6 +45430,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -39281,6 +45445,7 @@ private constructor( replacesPriceId == other.replacesPriceId && unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -39300,6 +45465,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -39314,6 +45480,7 @@ private constructor( replacesPriceId, unitWithPercentConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -39321,7 +45488,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MatrixWithAllocation @@ -39341,6 +45508,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val matrixWithAllocationConfig: JsonField, @@ -39355,6 +45523,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -39398,6 +45567,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -39431,6 +45603,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -39446,6 +45621,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixWithAllocationConfig, @@ -39460,6 +45636,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -39554,6 +45731,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -39662,6 +45846,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -39792,6 +45985,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -39917,6 +46120,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -39950,6 +46162,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixWithAllocationConfig() @@ -39984,6 +46197,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var matrixWithAllocationConfig: JsonField? = null @@ -39999,6 +46213,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -40018,6 +46233,7 @@ private constructor( discount = matrixWithAllocation.discount externalPriceId = matrixWithAllocation.externalPriceId fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = matrixWithAllocation.invoicingCycleConfiguration item = matrixWithAllocation.item matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig @@ -40032,6 +46248,7 @@ private constructor( priceType = matrixWithAllocation.priceType replacesPriceId = matrixWithAllocation.replacesPriceId dimensionalPriceConfiguration = matrixWithAllocation.dimensionalPriceConfiguration + licenseType = matrixWithAllocation.licenseType additionalProperties = matrixWithAllocation.additionalProperties.toMutableMap() } @@ -40410,6 +46627,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -40661,6 +46899,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -40701,6 +46962,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .matrixWithAllocationConfig() @@ -40735,6 +46997,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), @@ -40749,12 +47012,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MatrixWithAllocation = apply { if (validated) { return@apply @@ -40774,6 +47047,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() matrixWithAllocationConfig().validate() @@ -40792,6 +47066,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -40826,6 +47101,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -40839,7 +47115,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -40932,6 +47209,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -41084,6 +47371,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -41333,6 +47630,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -41476,6 +47783,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -41608,6 +47925,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -41734,6 +48061,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -41872,6 +48209,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -41910,6 +48257,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -41930,6 +48545,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithAllocationConfig == other.matrixWithAllocationConfig && @@ -41944,6 +48560,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -41963,6 +48580,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, matrixWithAllocationConfig, @@ -41977,6 +48595,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -41984,10 +48603,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class TieredWithProration + class MatrixWithThresholdDiscounts @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -42004,8 +48623,11 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -42016,8 +48638,8 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val tieredWithProrationConfig: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -42061,10 +48683,17 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: JsonField = + JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -42087,13 +48716,13 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -42109,8 +48738,10 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, + matrixWithThresholdDiscountsConfig, maximum, maximumAmount, metadata, @@ -42121,8 +48752,8 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - tieredWithProrationConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -42217,6 +48848,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -42233,6 +48871,15 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") + /** + * Configuration for matrix_with_threshold_discounts pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired("matrix_with_threshold_discounts_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -42274,7 +48921,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -42310,20 +48957,20 @@ private constructor( fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + fun licenseType(): Optional = licenseType.getOptional("license_type") /** * Returns the raw JSON value of [id]. @@ -42455,6 +49102,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -42473,6 +49130,17 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): JsonField = + matrixWithThresholdDiscountsConfig + /** * Returns the raw JSON value of [maximum]. * @@ -42558,17 +49226,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -42580,6 +49237,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -42595,7 +49261,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredWithProration]. + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscounts]. * * The following fields are required: * ```java @@ -42613,8 +49280,10 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() + * .matrixWithThresholdDiscountsConfig() * .maximum() * .maximumAmount() * .metadata() @@ -42624,13 +49293,12 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [MatrixWithThresholdDiscounts]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -42647,55 +49315,65 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = JsonValue.from("matrix_with_threshold_discounts") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var tieredWithProrationConfig: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - id = tieredWithProration.id - billableMetric = tieredWithProration.billableMetric - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - billingMode = tieredWithProration.billingMode - cadence = tieredWithProration.cadence + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = apply { + id = matrixWithThresholdDiscounts.id + billableMetric = matrixWithThresholdDiscounts.billableMetric + billingCycleConfiguration = matrixWithThresholdDiscounts.billingCycleConfiguration + billingMode = matrixWithThresholdDiscounts.billingMode + cadence = matrixWithThresholdDiscounts.cadence compositePriceFilters = - tieredWithProration.compositePriceFilters.map { it.toMutableList() } - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - createdAt = tieredWithProration.createdAt - creditAllocation = tieredWithProration.creditAllocation - currency = tieredWithProration.currency - discount = tieredWithProration.discount - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration - item = tieredWithProration.item - maximum = tieredWithProration.maximum - maximumAmount = tieredWithProration.maximumAmount - metadata = tieredWithProration.metadata - minimum = tieredWithProration.minimum - minimumAmount = tieredWithProration.minimumAmount - modelType = tieredWithProration.modelType - name = tieredWithProration.name - planPhaseOrder = tieredWithProration.planPhaseOrder - priceType = tieredWithProration.priceType - replacesPriceId = tieredWithProration.replacesPriceId - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - dimensionalPriceConfiguration = tieredWithProration.dimensionalPriceConfiguration - additionalProperties = tieredWithProration.additionalProperties.toMutableMap() + matrixWithThresholdDiscounts.compositePriceFilters.map { it.toMutableList() } + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + createdAt = matrixWithThresholdDiscounts.createdAt + creditAllocation = matrixWithThresholdDiscounts.creditAllocation + currency = matrixWithThresholdDiscounts.currency + discount = matrixWithThresholdDiscounts.discount + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithThresholdDiscounts.invoicingCycleConfiguration + item = matrixWithThresholdDiscounts.item + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + maximum = matrixWithThresholdDiscounts.maximum + maximumAmount = matrixWithThresholdDiscounts.maximumAmount + metadata = matrixWithThresholdDiscounts.metadata + minimum = matrixWithThresholdDiscounts.minimum + minimumAmount = matrixWithThresholdDiscounts.minimumAmount + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + planPhaseOrder = matrixWithThresholdDiscounts.planPhaseOrder + priceType = matrixWithThresholdDiscounts.priceType + replacesPriceId = matrixWithThresholdDiscounts.replacesPriceId + dimensionalPriceConfiguration = + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + licenseType = matrixWithThresholdDiscounts.licenseType + additionalProperties = + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -43073,6 +49751,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -43111,6 +49810,24 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = matrixWithThresholdDiscountsConfig(JsonField.of(matrixWithThresholdDiscountsConfig)) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -43209,7 +49926,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -43286,21 +50003,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = - tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -43324,6 +50026,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -43344,7 +50069,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -43364,8 +50089,10 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() + * .matrixWithThresholdDiscountsConfig() * .maximum() * .maximumAmount() * .metadata() @@ -43375,13 +50102,12 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -43398,8 +50124,13 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired( + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, + ), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -43410,15 +50141,24 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { if (validated) { return@apply } @@ -43437,15 +50177,17 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() + matrixWithThresholdDiscountsConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -43453,8 +50195,8 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - tieredWithProrationConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -43489,20 +50231,24 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -43595,6 +50341,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -43747,6 +50503,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -43996,6 +50762,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -44139,139 +50915,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Field = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object + * Validates that the types of all values in this object match their expected types * recursively. * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Field && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Should prices that match the filter be included or excluded. */ - class Operator @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INCLUDES = of("includes") - - @JvmField val EXCLUDES = of("excludes") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - INCLUDES, - EXCLUDES, - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCLUDES, - EXCLUDES, - /** - * An enum member indicating that [Operator] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCLUDES -> Value.INCLUDES - EXCLUDES -> Value.EXCLUDES - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun known(): Known = - when (this) { - INCLUDES -> Known.INCLUDES - EXCLUDES -> Known.EXCLUDES - else -> throw OrbInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { + fun validate(): Field = apply { if (validated) { return@apply } @@ -44301,7 +50955,7 @@ private constructor( return true } - return other is Operator && value == other.value + return other is Field && value == other.value } override fun hashCode() = value.hashCode() @@ -44309,301 +50963,301 @@ private constructor( override fun toString() = value.toString() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CompositePriceFilter && - field == other.field && - operator == other.operator && - values == other.values && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, operator, values, additionalProperties) - } - - override fun hashCode(): Int = hashCode + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { - override fun toString() = - "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * 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 - ) { + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val INCLUDES = of("includes") - fun toBuilder() = Builder().from(this) + @JvmField val EXCLUDES = of("excludes") - companion object { + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - 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) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + 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) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $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) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + known() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [Metadata]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Metadata = apply { - if (validated) { - return@apply + return other is Operator && value == other.value } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && additionalProperties == other.additionalProperties + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) /** - * Returns this class instance's raw value. + * Unit price used for usage that does not match any defined matrix cell. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } + fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * First matrix dimension key. * - * 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. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun firstDimension(): String = firstDimension.getRequired("first_dimension") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Per-cell unit prices. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } + fun matrixValues(): List = matrixValues.getRequired("matrix_values") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * Optional second matrix dimension key. * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [defaultUnitAmount]. * - * Used for best match union deserialization. + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PriceType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * Returns the raw JSON value of [secondDimension]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun tiers(): List = tiers.getRequired("tiers") + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension /** - * Returns the raw JSON value of [tiers]. + * Returns the raw JSON value of [thresholdDiscountGroups]. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -44621,58 +51275,156 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [MatrixWithThresholdDiscountsConfig]. * * The following fields are required: * ```java - * .tiers() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + internal fun from( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = apply { + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { it.toMutableList() } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() + matrixWithThresholdDiscountsConfig.additionalProperties.toMutableMap() } + /** Unit price used for usage that does not match any defined matrix cell. */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.firstDimension] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` value + * You should usually call [Builder.firstDimension] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension } + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) } } + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups(thresholdDiscountGroups: List) = + thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThresholdDiscountGroup(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -44696,32 +51448,52 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } validated = true } @@ -44741,39 +51513,44 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + class MatrixValue @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tierLowerBound: JsonField, + private val firstDimensionValue: JsonField, private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tier_lower_bound") + @JsonProperty("first_dimension_value") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), + firstDimensionValue: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, unitAmount, secondDimensionValue, mutableMapOf()) /** - * Inclusive tier starting value - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") /** - * Amount per unit - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -44781,14 +51558,21 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [tierLowerBound]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("first_dimension_value") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _firstDimensionValue(): JsonField = firstDimensionValue /** * Returns the raw JSON value of [unitAmount]. @@ -44800,6 +51584,16 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -44815,47 +51609,47 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tier]. + * Returns a mutable builder for constructing an instance of [MatrixValue]. * * The following fields are required: * ```java - * .tierLowerBound() + * .firstDimensionValue() * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Tier]. */ + /** A builder for [MatrixValue]. */ class Builder internal constructor() { - private var tierLowerBound: JsonField? = null + private var firstDimensionValue: JsonField? = null private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = matrixValue.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed [String] - * value instead. This method is primarily for setting the field to an + * You should usually call [Builder.firstDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue } - /** Amount per unit */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -44869,6 +51663,27 @@ private constructor( this.unitAmount = unitAmount } + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -44892,35 +51707,47 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [MatrixValue]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tierLowerBound() + * .firstDimensionValue() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), checkRequired("unitAmount", unitAmount), + secondDimensionValue, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Tier = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixValue = apply { if (validated) { return@apply } - tierLowerBound() + firstDimensionValue() unitAmount() + secondDimensionValue() validated = true } @@ -44940,2583 +51767,2730 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Tier && - tierLowerBound == other.tierLowerBound && + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is TieredWithProrationConfig && - tiers == other.tiers && - additionalProperties == other.additionalProperties - } + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) - override fun hashCode(): Int = hashCode + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) - override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } + /** + * Semicolon-separated list of matrix cell coordinates targeted by this group. Each + * coordinate is `first,second` when the matrix has two dimensions, or just `first` + * for a single-dimension matrix. Example: `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cellCoordinates(): String = cellCoordinates.getRequired("cell_coordinates") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun thresholdAmount(): String = thresholdAmount.getRequired("threshold_amount") - return other is TieredWithProration && - id == other.id && - billableMetric == other.billableMetric && - billingCycleConfiguration == other.billingCycleConfiguration && - billingMode == other.billingMode && - cadence == other.cadence && - compositePriceFilters == other.compositePriceFilters && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - createdAt == other.createdAt && - creditAllocation == other.creditAllocation && - currency == other.currency && - discount == other.discount && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - item == other.item && - maximum == other.maximum && - maximumAmount == other.maximumAmount && - metadata == other.metadata && - minimum == other.minimum && - minimumAmount == other.minimumAmount && - modelType == other.modelType && - name == other.name && - planPhaseOrder == other.planPhaseOrder && - priceType == other.priceType && - replacesPriceId == other.replacesPriceId && - tieredWithProrationConfig == other.tieredWithProrationConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - additionalProperties == other.additionalProperties - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") - private val hashCode: Int by lazy { - Objects.hash( - id, - billableMetric, - billingCycleConfiguration, - billingMode, - cadence, - compositePriceFilters, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - tieredWithProrationConfig, - dimensionalPriceConfiguration, - additionalProperties, - ) - } + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage - override fun toString() = - "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates - class UnitWithProration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val billableMetric: JsonField, - private val billingCycleConfiguration: JsonField, - private val billingMode: JsonField, - private val cadence: JsonField, - private val compositePriceFilters: JsonField>, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val createdAt: JsonField, - private val creditAllocation: JsonField, - private val currency: JsonField, - private val discount: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val item: JsonField, - private val maximum: JsonField, - private val maximumAmount: JsonField, - private val metadata: JsonField, - private val minimum: JsonField, - private val minimumAmount: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val planPhaseOrder: JsonField, - private val priceType: JsonField, - private val replacesPriceId: JsonField, - private val unitWithProrationConfig: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("billing_mode") - @ExcludeMissing - billingMode: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("composite_price_filters") - @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - priceType: JsonField = JsonMissing.of(), - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - unitWithProrationConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - ) : this( - id, - billableMetric, - billingCycleConfiguration, - billingMode, - cadence, - compositePriceFilters, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - unitWithProrationConfig, - dimensionalPriceConfiguration, - mutableMapOf(), - ) + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun billableMetric(): Optional = - billableMetric.getOptional("billable_metric") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") + fun toBuilder() = Builder().from(this) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + companion object { - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun compositePriceFilters(): Optional> = - compositePriceFilters.getOptional("composite_price_filters") + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage(aboveThresholdDiscountPercentage: String) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun creditAllocation(): Optional = - creditAllocation.getOptional("credit_allocation") + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = aboveThresholdDiscountPercentage + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun currency(): String = currency.getRequired("currency") + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + */ + fun belowThresholdDiscountPercentage(belowThresholdDiscountPercentage: String) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discount(): Optional = discount.getOptional("discount") + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = belowThresholdDiscountPercentage + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + /** + * Semicolon-separated list of matrix cell coordinates targeted by this group. + * Each coordinate is `first,second` when the matrix has two dimensions, or just + * `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) - /** - * A minimal representation of an Item containing only the essential identifying - * information. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun item(): ItemSlim = item.getRequired("item") + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun maximum(): Optional = maximum.getOptional("maximum") + fun description(description: String?) = + description(JsonField.ofNullable(description)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = + description(description.getOrNull()) - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun minimum(): Optional = minimum.getOptional("minimum") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * The pricing model type - * - * 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). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceType(): PriceType = priceType.getRequired("price_type") + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } - /** - * The price id this price replaces. This price will take the place of the replaced price in - * plan version migrations. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") + private var validated: Boolean = false - /** - * Configuration for unit_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [billableMetric]. - * - * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [billingMode]. - * - * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billing_mode") - @ExcludeMissing - fun _billingMode(): JsonField = billingMode + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [compositePriceFilters]. - * - * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("composite_price_filters") - @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [creditAllocation]. - * - * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [discount]. - * - * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discount") - @ExcludeMissing - fun _discount(): JsonField = discount + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. + * 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`. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [item]. - * - * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + companion object { - /** - * Returns the raw JSON value of [maximum]. - * - * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [minimum]. - * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [priceType]. - * - * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [unitWithProrationConfig]. - * - * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = unitWithProrationConfig + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + private var validated: Boolean = false - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + validated = true + } - fun toBuilder() = Builder().from(this) - - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of [UnitWithProration]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```java - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .billingMode() - * .cadence() - * .compositePriceFilters() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * .unitWithProrationConfig() - * ``` + * Used for best match union deserialization. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProration]. */ - class Builder internal constructor() { + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var billingMode: JsonField? = null - private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null - private var conversionRate: JsonField? = null - private var conversionRateConfig: JsonField? = null - private var createdAt: JsonField? = null - private var creditAllocation: JsonField? = null - private var currency: JsonField? = null - private var discount: JsonField? = null - private var externalPriceId: JsonField? = null - private var fixedPriceQuantity: JsonField? = null - private var invoicingCycleConfiguration: JsonField? = null - private var item: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var metadata: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("unit_with_proration") - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var replacesPriceId: JsonField? = null - private var unitWithProrationConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmSynthetic - internal fun from(unitWithProration: UnitWithProration) = apply { - id = unitWithProration.id - billableMetric = unitWithProration.billableMetric - billingCycleConfiguration = unitWithProration.billingCycleConfiguration - billingMode = unitWithProration.billingMode - cadence = unitWithProration.cadence - compositePriceFilters = - unitWithProration.compositePriceFilters.map { it.toMutableList() } - conversionRate = unitWithProration.conversionRate - conversionRateConfig = unitWithProration.conversionRateConfig - createdAt = unitWithProration.createdAt - creditAllocation = unitWithProration.creditAllocation - currency = unitWithProration.currency - discount = unitWithProration.discount - externalPriceId = unitWithProration.externalPriceId - fixedPriceQuantity = unitWithProration.fixedPriceQuantity - invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration - item = unitWithProration.item - maximum = unitWithProration.maximum - maximumAmount = unitWithProration.maximumAmount - metadata = unitWithProration.metadata - minimum = unitWithProration.minimum - minimumAmount = unitWithProration.minimumAmount - modelType = unitWithProration.modelType - name = unitWithProration.name - planPhaseOrder = unitWithProration.planPhaseOrder - priceType = unitWithProration.priceType - replacesPriceId = unitWithProration.replacesPriceId - unitWithProrationConfig = unitWithProration.unitWithProrationConfig - dimensionalPriceConfiguration = unitWithProration.dimensionalPriceConfiguration - additionalProperties = unitWithProration.additionalProperties.toMutableMap() + return other is Metadata && additionalProperties == other.additionalProperties } - fun id(id: String) = id(JsonField.of(id)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } + override fun hashCode(): Int = hashCode - fun billableMetric(billableMetric: BillableMetricTiny?) = - billableMetric(JsonField.ofNullable(billableMetric)) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.getOrNull()) + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Sets [Builder.billableMetric] to an arbitrary JSON value. + * Returns this class instance's raw value. * - * You should usually call [Builder.billableMetric] with a well-typed - * [BillableMetricTiny] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + companion object { - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + @JvmField val USAGE_PRICE = of("usage_price") - fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + @JvmField val FIXED_PRICE = of("fixed_price") - /** - * Sets [Builder.billingMode] to an arbitrary JSON value. - * - * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun billingMode(billingMode: JsonField) = apply { - this.billingMode = billingMode + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * 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. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun compositePriceFilters(compositePriceFilters: List?) = - compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * Alias for calling [Builder.compositePriceFilters] with - * `compositePriceFilters.orElse(null)`. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - fun compositePriceFilters(compositePriceFilters: Optional>) = - compositePriceFilters(compositePriceFilters.getOrNull()) + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } /** - * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. */ - fun compositePriceFilters( - compositePriceFilters: JsonField> - ) = apply { - this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } - } + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } /** - * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * Returns this class instance's primitive wire representation. * - * @throws IllegalStateException if the field was previously set to a non-list. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { - compositePriceFilters = - (compositePriceFilters ?: JsonField.of(mutableListOf())).also { - checkKnown("compositePriceFilters", it).add(compositePriceFilter) - } - } + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + private var validated: Boolean = false /** - * Alias for [Builder.conversionRate]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + fun validate(): PriceType = apply { + if (validated) { + return@apply + } - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value } - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + override fun hashCode() = value.hashCode() - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * The Orb-assigned unique identifier for the license type. * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun conversionRateConfig(conversionRateConfig: JsonField) = - apply { - this.conversionRateConfig = conversionRateConfig - } + fun id(): String = id.getRequired("id") /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) + fun name(): String = name.getRequired("name") /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey /** - * Sets [Builder.createdAt] to an arbitrary JSON value. + * Returns the raw JSON value of [name]. * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun creditAllocation(creditAllocation: Allocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. - */ - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.getOrNull()) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.creditAllocation] to an arbitrary JSON value. - * - * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun currency(currency: String) = currency(JsonField.of(currency)) + /** A builder for [LicenseType]. */ + class Builder internal constructor() { - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } - /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ - @Deprecated("deprecated") - fun discount(discount: Optional) = discount(discount.getOrNull()) + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) - /** - * Sets [Builder.discount] to an arbitrary JSON value. - * - * You should usually call [Builder.discount] with a well-typed [Discount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) - /** - * Alias for calling [discount] with the following: - * ```java - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Alias for calling [discount] with the following: - * ```java - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Alias for calling [discount] with the following: - * ```java - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + private var validated: Boolean = false /** - * Alias for [Builder.fixedPriceQuantity]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: BillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + id() + groupingKey() + name() + validated = true + } - /** - * A minimal representation of an Item containing only the essential identifying - * information. - */ - fun item(item: ItemSlim) = item(JsonField.of(item)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.item] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun item(item: JsonField) = apply { this.item = item } + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ - @Deprecated("deprecated") - fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + override fun hashCode(): Int = hashCode - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and - * the entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + return other is MatrixWithThresholdDiscounts && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + matrixWithThresholdDiscountsConfig == other.matrixWithThresholdDiscountsConfig && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && + additionalProperties == other.additionalProperties + } - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + matrixWithThresholdDiscountsConfig, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + licenseType, + additionalProperties, + ) + } - /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ - @Deprecated("deprecated") - fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.minimum] to an arbitrary JSON value. - * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + override fun toString() = + "MatrixWithThresholdDiscounts{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + } - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val tieredWithProrationConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.getOrNull()) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + tieredWithProrationConfig, + dimensionalPriceConfiguration, + licenseType, + mutableMapOf(), + ) - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") - /** - * 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("unit_with_proration") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): Optional = + billableMetric.getOptional("billable_metric") - fun name(name: String) = name(JsonField.of(name)) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - /** - * Sets [Builder.priceType] to an arbitrary JSON value. - * - * You should usually call [Builder.priceType] with a well-typed [PriceType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Optional = + creditAllocation.getOptional("credit_allocation") - /** - * The price id this price replaces. This price will take the place of the replaced - * price in plan version migrations. - */ - fun replacesPriceId(replacesPriceId: String?) = - replacesPriceId(JsonField.ofNullable(replacesPriceId)) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") - /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ - fun replacesPriceId(replacesPriceId: Optional) = - replacesPriceId(replacesPriceId.getOrNull()) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discount(): Optional = discount.getOptional("discount") - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") - /** Configuration for unit_with_proration pricing */ - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.unitWithProrationConfig] with a well-typed - * [UnitWithProrationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [DimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Optional = maximum.getOptional("maximum") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Optional = minimum.getOptional("minimum") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Returns an immutable instance of [UnitWithProration]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .billingMode() - * .cadence() - * .compositePriceFilters() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * .unitWithProrationConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnitWithProration = - UnitWithProration( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("billingMode", billingMode), - checkRequired("cadence", cadence), - checkRequired("compositePriceFilters", compositePriceFilters).map { - it.toImmutable() - }, - checkRequired("conversionRate", conversionRate), - checkRequired("conversionRateConfig", conversionRateConfig), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - modelType, - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("replacesPriceId", replacesPriceId), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), - dimensionalPriceConfiguration, - additionalProperties.toMutableMap(), - ) - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") - private var validated: Boolean = false + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") - fun validate(): UnitWithProration = apply { - if (validated) { - return@apply - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceType(): PriceType = priceType.getRequired("price_type") - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - billingMode().validate() - cadence().validate() - compositePriceFilters().ifPresent { it.forEach { it.validate() } } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - createdAt() - creditAllocation().ifPresent { it.validate() } - currency() - discount().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoicingCycleConfiguration().ifPresent { it.validate() } - item().validate() - maximum().ifPresent { it.validate() } - maximumAmount() - metadata().validate() - minimum().ifPresent { it.validate() } - minimumAmount() - _modelType().let { - if (it != JsonValue.from("unit_with_proration")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - planPhaseOrder() - priceType().validate() - replacesPriceId() - unitWithProrationConfig().validate() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. * - * Used for best match union deserialization. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (billingMode.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (discount.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (item.asKnown().getOrNull()?.validity() ?: 0) + - (maximum.asKnown().getOrNull()?.validity() ?: 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (minimum.asKnown().getOrNull()?.validity() ?: 0) + - (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("unit_with_proration")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (priceType.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + fun licenseType(): Optional = licenseType.getOptional("license_type") - class BillingMode @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - companion object { + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JvmField val IN_ADVANCE = of("in_advance") + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode - @JvmField val IN_ARREAR = of("in_arrear") + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) - } + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters - /** An enum containing [BillingMode]'s known values. */ - enum class Known { - IN_ADVANCE, - IN_ARREAR, - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [BillingMode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - IN_ADVANCE, - IN_ARREAR, - /** - * An enum member indicating that [BillingMode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - IN_ADVANCE -> Value.IN_ADVANCE - IN_ARREAR -> Value.IN_ARREAR - else -> Value._UNKNOWN - } + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - IN_ADVANCE -> Known.IN_ADVANCE - IN_ARREAR -> Known.IN_ARREAR - else -> throw OrbInvalidDataException("Unknown BillingMode: $value") - } + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - private var validated: Boolean = false + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount - fun validate(): BillingMode = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - known() - validated = true - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - return other is BillingMode && value == other.value - } + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - class Cadence @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - companion object { + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmField val ONE_TIME = of("one_time") + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JvmField val MONTHLY = of("monthly") + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - @JvmField val QUARTERLY = of("quarterly") + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - @JvmField val SEMI_ANNUAL = of("semi_annual") + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - @JvmField val ANNUAL = of("annual") + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - @JvmField val CUSTOM = of("custom") + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * Returns a mutable builder for constructing an instance of [TieredWithProration]. * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * .tieredWithProrationConfig() + * ``` */ - enum class Value { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. - */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var tieredWithProrationConfig: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + id = tieredWithProration.id + billableMetric = tieredWithProration.billableMetric + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + billingMode = tieredWithProration.billingMode + cadence = tieredWithProration.cadence + compositePriceFilters = + tieredWithProration.compositePriceFilters.map { it.toMutableList() } + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + createdAt = tieredWithProration.createdAt + creditAllocation = tieredWithProration.creditAllocation + currency = tieredWithProration.currency + discount = tieredWithProration.discount + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + item = tieredWithProration.item + maximum = tieredWithProration.maximum + maximumAmount = tieredWithProration.maximumAmount + metadata = tieredWithProration.metadata + minimum = tieredWithProration.minimum + minimumAmount = tieredWithProration.minimumAmount + modelType = tieredWithProration.modelType + name = tieredWithProration.name + planPhaseOrder = tieredWithProration.planPhaseOrder + priceType = tieredWithProration.priceType + replacesPriceId = tieredWithProration.replacesPriceId + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + dimensionalPriceConfiguration = tieredWithProration.dimensionalPriceConfiguration + licenseType = tieredWithProration.licenseType + additionalProperties = tieredWithProration.additionalProperties.toMutableMap() } + fun id(id: String) = id(JsonField.of(id)) + /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Sets [Builder.id] to an arbitrary JSON value. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun value(): Value = - when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.getOrNull()) /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * Sets [Builder.billableMetric] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun known(): Known = - when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun validate(): Cadence = apply { - if (validated) { - return@apply - } + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) - known() - validated = true + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.cadence] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - return other is Cadence && value == other.value - } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) - override fun hashCode() = value.hashCode() + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) - override fun toString() = value.toString() - } - - class CompositePriceFilter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val field: JsonField, - private val operator: JsonField, - private val values: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("values") - @ExcludeMissing - values: JsonField> = JsonMissing.of(), - ) : this(field, operator, values, mutableMapOf()) + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } /** - * The property of the price to filter on. + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun field(): Field = field.getRequired("field") + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** - * Should prices that match the filter be included or excluded. + * Alias for [Builder.conversionRate]. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * This unboxed primitive overload exists for backwards compatibility. */ - fun operator(): Operator = operator.getRequired("operator") + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) /** - * The IDs or values that match this filter. + * Sets [Builder.conversionRate] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun values(): List = values.getRequired("values") + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. */ - @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) /** - * Returns the raw JSON value of [operator]. + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected - * type. + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - @JsonProperty("operator") - @ExcludeMissing - fun _operator(): JsonField = operator + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } /** - * Returns the raw JSON value of [values]. - * - * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. */ - @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) - companion object { + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - /** - * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. - * - * The following fields are required: - * ```java - * .field() - * .operator() - * .values() - * ``` - */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt } - /** A builder for [CompositePriceFilter]. */ - class Builder internal constructor() { + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) - private var field: JsonField? = null - private var operator: JsonField? = null - private var values: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. + */ + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.getOrNull()) - @JvmSynthetic - internal fun from(compositePriceFilter: CompositePriceFilter) = apply { - field = compositePriceFilter.field - operator = compositePriceFilter.operator - values = compositePriceFilter.values.map { it.toMutableList() } - additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } - /** The property of the price to filter on. */ - fun field(field: Field) = field(JsonField.of(field)) + fun currency(currency: String) = currency(JsonField.of(currency)) - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed [Field] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun field(field: JsonField) = apply { this.field = field } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** Should prices that match the filter be included or excluded. */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } + /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ + @Deprecated("deprecated") + fun discount(discount: Optional) = discount(discount.getOrNull()) - /** The IDs or values that match this filter. */ - fun values(values: List) = values(JsonField.of(values)) + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } - /** - * Sets [Builder.values] to an arbitrary JSON value. - * - * You should usually call [Builder.values] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun values(values: JsonField>) = apply { - this.values = values.map { it.toMutableList() } - } + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - /** - * Adds a single [String] to [values]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addValue(value: String) = apply { - values = - (values ?: JsonField.of(mutableListOf())).also { - checkKnown("values", it).add(value) - } - } + /** + * Alias for calling [discount] with the following: + * ```java + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Alias for calling [discount] with the following: + * ```java + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [discount] with the following: + * ```java + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) - /** - * Returns an immutable instance of [CompositePriceFilter]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .field() - * .operator() - * .values() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CompositePriceFilter = - CompositePriceFilter( - checkRequired("field", field), - checkRequired("operator", operator), - checkRequired("values", values).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - private var validated: Boolean = false + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun validate(): CompositePriceFilter = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - field().validate() - operator().validate() - values() - validated = true + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic - internal fun validity(): Int = - (field.asKnown().getOrNull()?.validity() ?: 0) + - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (values.asKnown().getOrNull()?.size ?: 0) + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** The property of the price to filter on. */ - class Field @JsonCreator private constructor(private val value: JsonField) : - Enum { + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - companion object { + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - @JvmField val PRICE_ID = of("price_id") + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) - @JvmField val ITEM_ID = of("item_id") + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } - @JvmField val PRICE_TYPE = of("price_type") + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - @JvmField val CURRENCY = of("currency") + /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ + @Deprecated("deprecated") + fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) - @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - @JvmStatic fun of(value: String) = Field(JsonField.of(value)) - } + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - /** An enum containing [Field]'s known values. */ - enum class Known { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - } + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) - /** - * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Field] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - /** - * An enum member indicating that [Field] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PRICE_ID -> Value.PRICE_ID - ITEM_ID -> Value.ITEM_ID - PRICE_TYPE -> Value.PRICE_TYPE - CURRENCY -> Value.CURRENCY - PRICING_UNIT_ID -> Value.PRICING_UNIT_ID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PRICE_ID -> Known.PRICE_ID - ITEM_ID -> Known.ITEM_ID - PRICE_TYPE -> Known.PRICE_TYPE - CURRENCY -> Known.CURRENCY - PRICING_UNIT_ID -> Known.PRICING_UNIT_ID - else -> throw OrbInvalidDataException("Unknown Field: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Field = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Field && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } - /** Should prices that match the filter be included or excluded. */ - class Operator @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INCLUDES = of("includes") - - @JvmField val EXCLUDES = of("excludes") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - INCLUDES, - EXCLUDES, - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCLUDES, - EXCLUDES, - /** - * An enum member indicating that [Operator] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCLUDES -> Value.INCLUDES - EXCLUDES -> Value.EXCLUDES - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCLUDES -> Known.INCLUDES - EXCLUDES -> Known.EXCLUDES - else -> throw OrbInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - return other is Operator && value == other.value - } + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - override fun hashCode() = value.hashCode() + /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ + @Deprecated("deprecated") + fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) - override fun toString() = value.toString() - } + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - return other is CompositePriceFilter && - field == other.field && - operator == other.operator && - values == other.values && - additionalProperties == other.additionalProperties - } + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) - private val hashCode: Int by lazy { - Objects.hash(field, operator, values, additionalProperties) + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - override fun hashCode(): Int = hashCode + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - override fun toString() = - "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" - } + fun name(name: String) = name(JsonField.of(name)) - /** - * 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 - ) { + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - companion object { + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder } - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ + fun replacesPriceId(replacesPriceId: Optional) = + replacesPriceId(replacesPriceId.getOrNull()) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = + tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - private var validated: Boolean = false + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - validated = true - } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.licenseType] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } - return other is Metadata && additionalProperties == other.additionalProperties + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns this class instance's raw value. + * Returns an immutable instance of [TieredWithProration]. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + dimensionalPriceConfiguration, + licenseType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + billingMode().validate() + cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + tieredWithProrationConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + modelType.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) + + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) + + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is * on an older version than the API, then the API may respond with new members that the * SDK is unaware of. */ @@ -47524,37 +54498,33 @@ private constructor( companion object { - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") + @JvmField val IN_ADVANCE = of("in_advance") - @JvmField val COMPOSITE_PRICE = of("composite_price") + @JvmField val IN_ARREAR = of("in_arrear") - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - /** An enum containing [PriceType]'s known values. */ + /** An enum containing [BillingMode]'s known values. */ enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, + IN_ADVANCE, + IN_ARREAR, } /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [PriceType] can contain an unknown value in a couple of cases: + * An instance of [BillingMode] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, + IN_ADVANCE, + IN_ARREAR, /** - * An enum member indicating that [PriceType] was instantiated with an unknown + * An enum member indicating that [BillingMode] was instantiated with an unknown * value. */ _UNKNOWN, @@ -47569,9 +54539,8 @@ private constructor( */ fun value(): Value = when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR else -> Value._UNKNOWN } @@ -47586,10 +54555,9 @@ private constructor( */ fun known(): Known = when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") } /** @@ -47606,7 +54574,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PriceType = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BillingMode = apply { if (validated) { return@apply } @@ -47636,7 +54614,7 @@ private constructor( return true } - return other is PriceType && value == other.value + return other is BillingMode && value == other.value } override fun hashCode() = value.hashCode() @@ -47644,39 +54622,238 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for unit_with_proration pricing */ - class UnitWithProrationConfig + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CompositePriceFilter @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitAmount: JsonField, + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_amount") + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of() - ) : this(unitAmount, mutableMapOf()) + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) /** - * Rate per unit of usage + * The property of the price to filter on. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun field(): Field = field.getRequired("field") /** - * Returns the raw JSON value of [unitAmount]. + * Should prices that match the filter be included or excluded. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("unit_amount") + @JsonProperty("operator") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -47693,42 +54870,82 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UnitWithProrationConfig]. + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. * * The following fields are required: * ```java - * .unitAmount() + * .field() + * .operator() + * .values() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnitWithProrationConfig]. */ + /** A builder for [CompositePriceFilter]. */ class Builder internal constructor() { - private var unitAmount: JsonField? = null + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { - unitAmount = unitWithProrationConfig.unitAmount - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() } - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.field] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed [String] value + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -47754,32 +54971,48 @@ private constructor( } /** - * Returns an immutable instance of [UnitWithProrationConfig]. + * Returns an immutable instance of [CompositePriceFilter]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .unitAmount() + * .field() + * .operator() + * .values() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig( - checkRequired("unitAmount", unitAmount), + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): UnitWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CompositePriceFilter = apply { if (validated) { return@apply } - unitAmount() + field().validate() + operator().validate() + values() validated = true } @@ -47798,1868 +55031,1249 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) - return other is UnitWithProrationConfig && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { - private val hashCode: Int by lazy { Objects.hash(unitAmount, 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 - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + @JvmField val PRICE_ID = of("price_id") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val ITEM_ID = of("item_id") - return other is UnitWithProration && - id == other.id && - billableMetric == other.billableMetric && - billingCycleConfiguration == other.billingCycleConfiguration && - billingMode == other.billingMode && - cadence == other.cadence && - compositePriceFilters == other.compositePriceFilters && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - createdAt == other.createdAt && - creditAllocation == other.creditAllocation && - currency == other.currency && - discount == other.discount && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - item == other.item && - maximum == other.maximum && - maximumAmount == other.maximumAmount && - metadata == other.metadata && - minimum == other.minimum && - minimumAmount == other.minimumAmount && - modelType == other.modelType && - name == other.name && - planPhaseOrder == other.planPhaseOrder && - priceType == other.priceType && - replacesPriceId == other.replacesPriceId && - unitWithProrationConfig == other.unitWithProrationConfig && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - additionalProperties == other.additionalProperties - } + @JvmField val PRICE_TYPE = of("price_type") - private val hashCode: Int by lazy { - Objects.hash( - id, - billableMetric, - billingCycleConfiguration, - billingMode, - cadence, - compositePriceFilters, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - unitWithProrationConfig, - dimensionalPriceConfiguration, - additionalProperties, - ) - } + @JvmField val CURRENCY = of("currency") - override fun hashCode(): Int = hashCode + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") - override fun toString() = - "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } - class GroupedAllocation - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val billableMetric: JsonField, - private val billingCycleConfiguration: JsonField, - private val billingMode: JsonField, - private val cadence: JsonField, - private val compositePriceFilters: JsonField>, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val createdAt: JsonField, - private val creditAllocation: JsonField, - private val currency: JsonField, - private val discount: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val groupedAllocationConfig: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val item: JsonField, - private val maximum: JsonField, - private val maximumAmount: JsonField, - private val metadata: JsonField, - private val minimum: JsonField, - private val minimumAmount: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val planPhaseOrder: JsonField, - private val priceType: JsonField, - private val replacesPriceId: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val additionalProperties: MutableMap, - ) { + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("billing_mode") - @ExcludeMissing - billingMode: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("composite_price_filters") - @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - groupedAllocationConfig: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - priceType: JsonField = JsonMissing.of(), - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - ) : this( - id, - billableMetric, - billingCycleConfiguration, - billingMode, - cadence, - compositePriceFilters, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - groupedAllocationConfig, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - dimensionalPriceConfiguration, - mutableMapOf(), - ) + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun billableMetric(): Optional = - billableMetric.getOptional("billable_metric") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + private var validated: Boolean = false - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Field = apply { + if (validated) { + return@apply + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun compositePriceFilters(): Optional> = - compositePriceFilters.getOptional("composite_price_filters") + known() + validated = true + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun creditAllocation(): Optional = - creditAllocation.getOptional("credit_allocation") + return other is Field && value == other.value + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun currency(): String = currency.getRequired("currency") + override fun hashCode() = value.hashCode() - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discount(): Optional = discount.getOptional("discount") + override fun toString() = value.toString() + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Configuration for grouped_allocation pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") + companion object { - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + @JvmField val INCLUDES = of("includes") - /** - * A minimal representation of an Item containing only the essential identifying - * information. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun item(): ItemSlim = item.getRequired("item") + @JvmField val EXCLUDES = of("excludes") - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun maximum(): Optional = maximum.getOptional("maximum") + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun minimum(): Optional = minimum.getOptional("minimum") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } - /** - * The pricing model type - * - * 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). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") + private var validated: Boolean = false - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceType(): PriceType = priceType.getRequired("price_type") + known() + validated = true + } - /** - * The price id this price replaces. This price will take the place of the replaced price in - * plan version migrations. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [billableMetric]. - * - * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + return other is Operator && value == other.value + } - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [billingMode]. - * - * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billing_mode") - @ExcludeMissing - fun _billingMode(): JsonField = billingMode + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [compositePriceFilters]. - * - * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("composite_price_filters") - @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } /** - * Returns the raw JSON value of [creditAllocation]. - * - * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected - * type. + * 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`. */ - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns the raw JSON value of [discount]. - * - * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discount") - @ExcludeMissing - fun _discount(): JsonField = discount + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + companion object { - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [groupedAllocationConfig]. - * - * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = groupedAllocationConfig + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [item]. - * - * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [maximum]. - * - * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [minimum]. - * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** - * Returns the raw JSON value of [planPhaseOrder]. - * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + private var validated: Boolean = false - /** - * Returns the raw JSON value of [priceType]. - * - * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + validated = true + } - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun toBuilder() = Builder().from(this) + return other is Metadata && additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns a mutable builder for constructing an instance of [GroupedAllocation]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .billingMode() - * .cadence() - * .compositePriceFilters() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .groupedAllocationConfig() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * ``` + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [GroupedAllocation]. */ - class Builder internal constructor() { + companion object { - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var billingMode: JsonField? = null - private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null - private var conversionRate: JsonField? = null - private var conversionRateConfig: JsonField? = null - private var createdAt: JsonField? = null - private var creditAllocation: JsonField? = null - private var currency: JsonField? = null - private var discount: JsonField? = null - private var externalPriceId: JsonField? = null - private var fixedPriceQuantity: JsonField? = null - private var groupedAllocationConfig: JsonField? = null - private var invoicingCycleConfiguration: JsonField? = null - private var item: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var metadata: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_allocation") - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var replacesPriceId: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val USAGE_PRICE = of("usage_price") - @JvmSynthetic - internal fun from(groupedAllocation: GroupedAllocation) = apply { - id = groupedAllocation.id - billableMetric = groupedAllocation.billableMetric - billingCycleConfiguration = groupedAllocation.billingCycleConfiguration - billingMode = groupedAllocation.billingMode - cadence = groupedAllocation.cadence - compositePriceFilters = - groupedAllocation.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedAllocation.conversionRate - conversionRateConfig = groupedAllocation.conversionRateConfig - createdAt = groupedAllocation.createdAt - creditAllocation = groupedAllocation.creditAllocation - currency = groupedAllocation.currency - discount = groupedAllocation.discount - externalPriceId = groupedAllocation.externalPriceId - fixedPriceQuantity = groupedAllocation.fixedPriceQuantity - groupedAllocationConfig = groupedAllocation.groupedAllocationConfig - invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration - item = groupedAllocation.item - maximum = groupedAllocation.maximum - maximumAmount = groupedAllocation.maximumAmount - metadata = groupedAllocation.metadata - minimum = groupedAllocation.minimum - minimumAmount = groupedAllocation.minimumAmount - modelType = groupedAllocation.modelType - name = groupedAllocation.name - planPhaseOrder = groupedAllocation.planPhaseOrder - priceType = groupedAllocation.priceType - replacesPriceId = groupedAllocation.replacesPriceId - dimensionalPriceConfiguration = groupedAllocation.dimensionalPriceConfiguration - additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } - fun id(id: String) = id(JsonField.of(id)) + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } /** - * Sets [Builder.id] to an arbitrary JSON value. + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * 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. */ - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetricTiny?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.getOrNull()) + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * Sets [Builder.billableMetric] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.billableMetric] with a well-typed - * [BillableMetricTiny] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + private var validated: Boolean = false /** - * Sets [Builder.billingMode] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun billingMode(billingMode: JsonField) = apply { - this.billingMode = billingMode + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun compositePriceFilters(compositePriceFilters: List?) = - compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [Builder.compositePriceFilters] with - * `compositePriceFilters.orElse(null)`. - */ - fun compositePriceFilters(compositePriceFilters: Optional>) = - compositePriceFilters(compositePriceFilters.getOrNull()) + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * Tiers for rating based on total usage quantities into the specified tier with + * proration * - * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun compositePriceFilters( - compositePriceFilters: JsonField> - ) = apply { - this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } - } + fun tiers(): List = tiers.getRequired("tiers") /** - * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * Returns the raw JSON value of [tiers]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. */ - fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { - compositePriceFilters = - (compositePriceFilters ?: JsonField.of(mutableListOf())).also { - checkKnown("compositePriceFilters", it).add(compositePriceFilter) - } + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + fun toBuilder() = Builder().from(this) - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + companion object { - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun conversionRateConfig(conversionRateConfig: JsonField) = - apply { - this.conversionRateConfig = conversionRateConfig + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() } - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun creditAllocation(creditAllocation: Allocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. - */ - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.getOrNull()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.creditAllocation] to an arbitrary JSON value. - * - * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - fun currency(currency: String) = currency(JsonField.of(currency)) + private var validated: Boolean = false /** - * Sets [Builder.currency] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun currency(currency: JsonField) = apply { this.currency = currency } + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + tiers().forEach { it.validate() } + validated = true + } - /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ - @Deprecated("deprecated") - fun discount(discount: Optional) = discount(discount.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.discount] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.discount] with a well-typed [Discount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Alias for calling [discount] with the following: - * ```java - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * Alias for calling [discount] with the following: - * ```java - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** - * Alias for calling [discount] with the following: - * ```java - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + companion object { - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** Configuration for grouped_allocation pricing */ - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - /** - * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedAllocationConfig] with a well-typed - * [GroupedAllocationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: BillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * A minimal representation of an Item containing only the essential identifying - * information. - */ - fun item(item: ItemSlim) = item(JsonField.of(item)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.item] to an arbitrary JSON value. - * - * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun item(item: JsonField) = apply { this.item = item } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ - @Deprecated("deprecated") - fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + private var validated: Boolean = false - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and - * the entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ - @Deprecated("deprecated") - fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.minimum] to an arbitrary JSON value. - * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.getOrNull()) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * The Orb-assigned unique identifier for the license type. * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + fun id(): String = id.getRequired("id") /** - * Sets the field to an arbitrary JSON value. + * The key used for grouping licenses of this type. This is typically a user identifier + * field. * - * 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. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Sets [Builder.name] to an arbitrary JSON value. + * The name of the license type. * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + fun name(): String = name.getRequired("name") /** - * Alias for [Builder.planPhaseOrder]. + * Returns the raw JSON value of [id]. * - * This unboxed primitive overload exists for backwards compatibility. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * Returns the raw JSON value of [groupingKey]. * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey /** - * Sets [Builder.priceType] to an arbitrary JSON value. + * Returns the raw JSON value of [name]. * - * You should usually call [Builder.priceType] with a well-typed [PriceType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * The price id this price replaces. This price will take the place of the replaced - * price in plan version migrations. - */ - fun replacesPriceId(replacesPriceId: String?) = - replacesPriceId(JsonField.ofNullable(replacesPriceId)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ - fun replacesPriceId(replacesPriceId: Optional) = - replacesPriceId(replacesPriceId.getOrNull()) - - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [DimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + companion object { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * Returns an immutable instance of [GroupedAllocation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .billingMode() - * .cadence() - * .compositePriceFilters() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .groupedAllocationConfig() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedAllocation = - GroupedAllocation( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("billingMode", billingMode), - checkRequired("cadence", cadence), - checkRequired("compositePriceFilters", compositePriceFilters).map { - it.toImmutable() - }, - checkRequired("conversionRate", conversionRate), - checkRequired("conversionRateConfig", conversionRateConfig), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - modelType, - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("replacesPriceId", replacesPriceId), - dimensionalPriceConfiguration, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + /** A builder for [LicenseType]. */ + class Builder internal constructor() { - fun validate(): GroupedAllocation = apply { - if (validated) { - return@apply - } + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - billingMode().validate() - cadence().validate() - compositePriceFilters().ifPresent { it.forEach { it.validate() } } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - createdAt() - creditAllocation().ifPresent { it.validate() } - currency() - discount().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - groupedAllocationConfig().validate() - invoicingCycleConfiguration().ifPresent { it.validate() } - item().validate() - maximum().ifPresent { it.validate() } - maximumAmount() - metadata().validate() - minimum().ifPresent { it.validate() } - minimumAmount() - _modelType().let { - if (it != JsonValue.from("grouped_allocation")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() } - } - name() - planPhaseOrder() - priceType().validate() - replacesPriceId() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (billingMode.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (discount.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (item.asKnown().getOrNull()?.validity() ?: 0) + - (maximum.asKnown().getOrNull()?.validity() ?: 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (minimum.asKnown().getOrNull()?.validity() ?: 0) + - (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (priceType.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - - class BillingMode @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - @JvmField val IN_ADVANCE = of("in_advance") - - @JvmField val IN_ARREAR = of("in_arrear") - - @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) - } - - /** An enum containing [BillingMode]'s known values. */ - enum class Known { - IN_ADVANCE, - IN_ARREAR, - } + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) - /** - * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [BillingMode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - IN_ADVANCE, - IN_ARREAR, /** - * An enum member indicating that [BillingMode] was instantiated with an unknown - * value. + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - _UNKNOWN, - } + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - IN_ADVANCE -> Value.IN_ADVANCE - IN_ARREAR -> Value.IN_ARREAR - else -> Value._UNKNOWN - } + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - IN_ADVANCE -> Known.IN_ADVANCE - IN_ARREAR -> Known.IN_ARREAR - else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) - private var validated: Boolean = false + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun validate(): BillingMode = apply { - if (validated) { - return@apply + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - return other is BillingMode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Cadence @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } - - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - _UNKNOWN, + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + private var validated: Boolean = false /** - * Returns this class instance's primitive wire representation. + * Validates that the types of all values in this object match their expected types + * recursively. * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Cadence = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - known() + id() + groupingKey() + name() validated = true } @@ -49677,91 +56291,13471 @@ 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 = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } - class CompositePriceFilter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val field: JsonField, - private val operator: JsonField, + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProration && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + tieredWithProrationConfig == other.tieredWithProrationConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + tieredWithProrationConfig, + dimensionalPriceConfiguration, + licenseType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + } + + class UnitWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val unitWithProrationConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + unitWithProrationConfig, + dimensionalPriceConfiguration, + licenseType, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): Optional = + billableMetric.getOptional("billable_metric") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Optional = + creditAllocation.getOptional("credit_allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discount(): Optional = discount.getOptional("discount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Optional = maximum.getOptional("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Optional = minimum.getOptional("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + + /** + * The pricing model type + * + * 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). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceType(): PriceType = priceType.getRequired("price_type") + + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") + + /** + * Configuration for unit_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [unitWithProrationConfig]. + * + * Unlike [unitWithProrationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = unitWithProrationConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitWithProration]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProration]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProration: UnitWithProration) = apply { + id = unitWithProration.id + billableMetric = unitWithProration.billableMetric + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + billingMode = unitWithProration.billingMode + cadence = unitWithProration.cadence + compositePriceFilters = + unitWithProration.compositePriceFilters.map { it.toMutableList() } + conversionRate = unitWithProration.conversionRate + conversionRateConfig = unitWithProration.conversionRateConfig + createdAt = unitWithProration.createdAt + creditAllocation = unitWithProration.creditAllocation + currency = unitWithProration.currency + discount = unitWithProration.discount + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + item = unitWithProration.item + maximum = unitWithProration.maximum + maximumAmount = unitWithProration.maximumAmount + metadata = unitWithProration.metadata + minimum = unitWithProration.minimum + minimumAmount = unitWithProration.minimumAmount + modelType = unitWithProration.modelType + name = unitWithProration.name + planPhaseOrder = unitWithProration.planPhaseOrder + priceType = unitWithProration.priceType + replacesPriceId = unitWithProration.replacesPriceId + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + dimensionalPriceConfiguration = unitWithProration.dimensionalPriceConfiguration + licenseType = unitWithProration.licenseType + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.getOrNull()) + + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + /** + * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. + */ + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.getOrNull()) + + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ + @Deprecated("deprecated") + fun discount(discount: Optional) = discount(discount.getOrNull()) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```java + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) + + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } + + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ + @Deprecated("deprecated") + fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ + @Deprecated("deprecated") + fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * Sets 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("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) + + /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ + fun replacesPriceId(replacesPriceId: Optional) = + replacesPriceId(replacesPriceId.getOrNull()) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** Configuration for unit_with_proration pricing */ + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + /** + * Sets [Builder.unitWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.unitWithProrationConfig] with a well-typed + * [UnitWithProrationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * .unitWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProration = + UnitWithProration( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + dimensionalPriceConfiguration, + licenseType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UnitWithProration = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + billingMode().validate() + cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + unitWithProrationConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("unit_with_proration")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) + + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PRICE_ID = of("price_id") + + @JvmField val ITEM_ID = of("item_id") + + @JvmField val PRICE_TYPE = of("price_type") + + @JvmField val CURRENCY = of("currency") + + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INCLUDES = of("includes") + + @JvmField val EXCLUDES = of("excludes") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for unit_with_proration pricing */ + class UnitWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of() + ) : this(unitAmount, mutableMapOf()) + + /** + * Rate per unit of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnitWithProrationConfig]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProrationConfig]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { + unitAmount = unitWithProrationConfig.unitAmount + additionalProperties = + unitWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnitWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnitWithProrationConfig = + UnitWithProrationConfig( + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UnitWithProrationConfig = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProrationConfig && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnitWithProration && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + unitWithProrationConfig == other.unitWithProrationConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + unitWithProrationConfig, + dimensionalPriceConfiguration, + licenseType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + } + + class GroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val groupedAllocationConfig: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedAllocationConfig, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + licenseType, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): Optional = + billableMetric.getOptional("billable_metric") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Optional = + creditAllocation.getOptional("credit_allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discount(): Optional = discount.getOptional("discount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * Configuration for grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Optional = maximum.getOptional("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Optional = minimum.getOptional("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + + /** + * The pricing model type + * + * 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). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceType(): PriceType = priceType.getRequired("price_type") + + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [groupedAllocationConfig]. + * + * Unlike [groupedAllocationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = groupedAllocationConfig + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedAllocation]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedAllocationConfig() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocation]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocation: GroupedAllocation) = apply { + id = groupedAllocation.id + billableMetric = groupedAllocation.billableMetric + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + billingMode = groupedAllocation.billingMode + cadence = groupedAllocation.cadence + compositePriceFilters = + groupedAllocation.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedAllocation.conversionRate + conversionRateConfig = groupedAllocation.conversionRateConfig + createdAt = groupedAllocation.createdAt + creditAllocation = groupedAllocation.creditAllocation + currency = groupedAllocation.currency + discount = groupedAllocation.discount + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + item = groupedAllocation.item + maximum = groupedAllocation.maximum + maximumAmount = groupedAllocation.maximumAmount + metadata = groupedAllocation.metadata + minimum = groupedAllocation.minimum + minimumAmount = groupedAllocation.minimumAmount + modelType = groupedAllocation.modelType + name = groupedAllocation.name + planPhaseOrder = groupedAllocation.planPhaseOrder + priceType = groupedAllocation.priceType + replacesPriceId = groupedAllocation.replacesPriceId + dimensionalPriceConfiguration = groupedAllocation.dimensionalPriceConfiguration + licenseType = groupedAllocation.licenseType + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.getOrNull()) + + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + /** + * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. + */ + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.getOrNull()) + + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ + @Deprecated("deprecated") + fun discount(discount: Optional) = discount(discount.getOrNull()) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```java + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** Configuration for grouped_allocation pricing */ + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + /** + * Sets [Builder.groupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedAllocationConfig] with a well-typed + * [GroupedAllocationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) + + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } + + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ + @Deprecated("deprecated") + fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ + @Deprecated("deprecated") + fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) + + /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ + fun replacesPriceId(replacesPriceId: Optional) = + replacesPriceId(replacesPriceId.getOrNull()) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedAllocationConfig() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocation = + GroupedAllocation( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + dimensionalPriceConfiguration, + licenseType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedAllocation = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + billingMode().validate() + cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + groupedAllocationConfig().validate() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) + + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PRICE_ID = of("price_id") + + @JvmField val ITEM_ID = of("item_id") + + @JvmField val PRICE_TYPE = of("price_type") + + @JvmField val CURRENCY = of("currency") + + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INCLUDES = of("includes") + + @JvmField val EXCLUDES = of("excludes") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** Configuration for grouped_allocation pricing */ + class GroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allocation: JsonField, + private val groupingKey: JsonField, + private val overageUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allocation") + @ExcludeMissing + allocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("overage_unit_rate") + @ExcludeMissing + overageUnitRate: JsonField = JsonMissing.of(), + ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + + /** + * Usage allocation per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allocation(): String = allocation.getRequired("allocation") + + /** + * How to determine the groups that should each be allocated some quantity + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * Unit rate for post-allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + + /** + * Returns the raw JSON value of [allocation]. + * + * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [overageUnitRate]. + * + * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("overage_unit_rate") + @ExcludeMissing + fun _overageUnitRate(): JsonField = overageUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var groupingKey: JsonField? = null + private var overageUnitRate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { + allocation = groupedAllocationConfig.allocation + groupingKey = groupedAllocationConfig.groupingKey + overageUnitRate = groupedAllocationConfig.overageUnitRate + additionalProperties = + groupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** Usage allocation per group */ + fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + + /** + * Sets [Builder.allocation] to an arbitrary JSON value. + * + * You should usually call [Builder.allocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** How to determine the groups that should each be allocated some quantity */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** Unit rate for post-allocation */ + fun overageUnitRate(overageUnitRate: String) = + overageUnitRate(JsonField.of(overageUnitRate)) + + /** + * Sets [Builder.overageUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.overageUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun overageUnitRate(overageUnitRate: JsonField) = apply { + this.overageUnitRate = overageUnitRate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allocation() + * .groupingKey() + * .overageUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedAllocationConfig = + GroupedAllocationConfig( + checkRequired("allocation", allocation), + checkRequired("groupingKey", groupingKey), + checkRequired("overageUnitRate", overageUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + allocation() + groupingKey() + overageUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (overageUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocationConfig && + allocation == other.allocation && + groupingKey == other.groupingKey && + overageUnitRate == other.overageUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedAllocation && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + groupedAllocationConfig == other.groupedAllocationConfig && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedAllocationConfig, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + licenseType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + } + + class BulkWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val bulkWithProrationConfig: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + bulkWithProrationConfig, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + licenseType, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): Optional = + billableMetric.getOptional("billable_metric") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + + /** + * Configuration for bulk_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Optional = + creditAllocation.getOptional("credit_allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discount(): Optional = discount.getOptional("discount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Optional = maximum.getOptional("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Optional = minimum.getOptional("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + + /** + * The pricing model type + * + * 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). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceType(): PriceType = priceType.getRequired("price_type") + + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + + /** + * Returns the raw JSON value of [bulkWithProrationConfig]. + * + * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithProration]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .bulkWithProrationConfig() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProration]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProration: BulkWithProration) = apply { + id = bulkWithProration.id + billableMetric = bulkWithProration.billableMetric + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + billingMode = bulkWithProration.billingMode + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + compositePriceFilters = + bulkWithProration.compositePriceFilters.map { it.toMutableList() } + conversionRate = bulkWithProration.conversionRate + conversionRateConfig = bulkWithProration.conversionRateConfig + createdAt = bulkWithProration.createdAt + creditAllocation = bulkWithProration.creditAllocation + currency = bulkWithProration.currency + discount = bulkWithProration.discount + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + item = bulkWithProration.item + maximum = bulkWithProration.maximum + maximumAmount = bulkWithProration.maximumAmount + metadata = bulkWithProration.metadata + minimum = bulkWithProration.minimum + minimumAmount = bulkWithProration.minimumAmount + modelType = bulkWithProration.modelType + name = bulkWithProration.name + planPhaseOrder = bulkWithProration.planPhaseOrder + priceType = bulkWithProration.priceType + replacesPriceId = bulkWithProration.replacesPriceId + dimensionalPriceConfiguration = bulkWithProration.dimensionalPriceConfiguration + licenseType = bulkWithProration.licenseType + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.getOrNull()) + + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + + /** Configuration for bulk_with_proration pricing */ + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + /** + * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithProrationConfig] with a well-typed + * [BulkWithProrationConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + /** + * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. + */ + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.getOrNull()) + + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ + @Deprecated("deprecated") + fun discount(discount: Optional) = discount(discount.getOrNull()) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```java + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) + + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } + + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ + @Deprecated("deprecated") + fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ + @Deprecated("deprecated") + fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * Sets 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("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) + + /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ + fun replacesPriceId(replacesPriceId: Optional) = + replacesPriceId(replacesPriceId.getOrNull()) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .bulkWithProrationConfig() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProration = + BulkWithProration( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + dimensionalPriceConfiguration, + licenseType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BulkWithProration = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + billingMode().validate() + bulkWithProrationConfig().validate() + cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + + (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) + + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for bulk_with_proration pricing */ + class BulkWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProrationConfig]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { + tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithProrationConfig.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithProrationConfig = + BulkWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BulkWithProrationConfig = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single bulk pricing tier with proration */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Cost per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Cost per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PRICE_ID = of("price_id") + + @JvmField val ITEM_ID = of("item_id") + + @JvmField val PRICE_TYPE = of("price_type") + + @JvmField val CURRENCY = of("currency") + + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INCLUDES = of("includes") + + @JvmField val EXCLUDES = of("excludes") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithProration && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + bulkWithProrationConfig == other.bulkWithProrationConfig && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + bulkWithProrationConfig, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + licenseType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + } + + class GroupedWithProratedMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val groupedWithProratedMinimumConfig: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedWithProratedMinimumConfig, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + licenseType, + mutableMapOf(), + ) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): Optional = + billableMetric.getOptional("billable_metric") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Optional = + creditAllocation.getOptional("credit_allocation") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discount(): Optional = discount.getOptional("discount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * Configuration for grouped_with_prorated_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Optional = maximum.getOptional("maximum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Optional = minimum.getOptional("minimum") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + + /** + * The pricing model type + * + * 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). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun priceType(): PriceType = priceType.getRequired("price_type") + + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. + * + * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): JsonField = + groupedWithProratedMinimumConfig + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimum]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedWithProratedMinimumConfig() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimum]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var invoiceGroupingKey: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_with_prorated_minimum") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { + id = groupedWithProratedMinimum.id + billableMetric = groupedWithProratedMinimum.billableMetric + billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration + billingMode = groupedWithProratedMinimum.billingMode + cadence = groupedWithProratedMinimum.cadence + compositePriceFilters = + groupedWithProratedMinimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedWithProratedMinimum.conversionRate + conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig + createdAt = groupedWithProratedMinimum.createdAt + creditAllocation = groupedWithProratedMinimum.creditAllocation + currency = groupedWithProratedMinimum.currency + discount = groupedWithProratedMinimum.discount + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = groupedWithProratedMinimum.invoicingCycleConfiguration + item = groupedWithProratedMinimum.item + maximum = groupedWithProratedMinimum.maximum + maximumAmount = groupedWithProratedMinimum.maximumAmount + metadata = groupedWithProratedMinimum.metadata + minimum = groupedWithProratedMinimum.minimum + minimumAmount = groupedWithProratedMinimum.minimumAmount + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + planPhaseOrder = groupedWithProratedMinimum.planPhaseOrder + priceType = groupedWithProratedMinimum.priceType + replacesPriceId = groupedWithProratedMinimum.replacesPriceId + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + licenseType = groupedWithProratedMinimum.licenseType + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.getOrNull()) + + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + /** + * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. + */ + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.getOrNull()) + + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ + @Deprecated("deprecated") + fun discount(discount: Optional) = discount(discount.getOrNull()) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```java + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + + /** + * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithProratedMinimumConfig] with a well-typed + * [GroupedWithProratedMinimumConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) + + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } + + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ + @Deprecated("deprecated") + fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ + @Deprecated("deprecated") + fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) + + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) + + /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ + fun replacesPriceId(replacesPriceId: Optional) = + replacesPriceId(replacesPriceId.getOrNull()) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedWithProratedMinimumConfig() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + dimensionalPriceConfiguration, + licenseType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedWithProratedMinimum = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + billingMode().validate() + cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + groupedWithProratedMinimumConfig().validate() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) + + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IN_ADVANCE = of("in_advance") + + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) + } + + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } + + /** + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, private val values: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("values") + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") + + /** + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun values(): List = values.getRequired("values") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [values]. + * + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } + + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) + + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PRICE_ID = of("price_id") + + @JvmField val ITEM_ID = of("item_id") + + @JvmField val PRICE_TYPE = of("price_type") + + @JvmField val CURRENCY = of("currency") + + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Field && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INCLUDES = of("includes") + + @JvmField val EXCLUDES = of("excludes") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** Configuration for grouped_with_prorated_minimum pricing */ + class GroupedWithProratedMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimum: JsonField, + private val unitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + minimum: JsonField = JsonMissing.of(), + @JsonProperty("unit_rate") + @ExcludeMissing + unitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + + /** + * How to determine the groups that should each have a minimum + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The minimum amount to charge per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimum(): String = minimum.getRequired("minimum") + + /** + * The amount to charge per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitRate(): String = unitRate.getRequired("unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + /** + * Returns the raw JSON value of [unitRate]. + * + * Unlike [unitRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_rate") @ExcludeMissing fun _unitRate(): JsonField = unitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimum: JsonField? = null + private var unitRate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = apply { + groupingKey = groupedWithProratedMinimumConfig.groupingKey + minimum = groupedWithProratedMinimumConfig.minimum + unitRate = groupedWithProratedMinimumConfig.unitRate + additionalProperties = + groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + } + + /** How to determine the groups that should each have a minimum */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group */ + fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + /** The amount to charge per unit */ + fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + + /** + * Sets [Builder.unitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitRate(unitRate: JsonField) = apply { this.unitRate = unitRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimum() + * .unitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithProratedMinimumConfig = + GroupedWithProratedMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimum", minimum), + checkRequired("unitRate", unitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + minimum() + unitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimum.asKnown().isPresent) 1 else 0) + + (if (unitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithProratedMinimumConfig && + groupingKey == other.groupingKey && + minimum == other.minimum && + unitRate == other.unitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") @ExcludeMissing - values: JsonField> = JsonMissing.of(), - ) : this(field, operator, values, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) /** - * The property of the price to filter on. + * The Orb-assigned unique identifier for the license type. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun field(): Field = field.getRequired("field") + fun id(): String = id.getRequired("id") /** - * Should prices that match the filter be included or excluded. + * The key used for grouping licenses of this type. This is typically a user identifier + * field. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun operator(): Operator = operator.getRequired("operator") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The IDs or values that match this filter. + * The name of the license type. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun values(): List = values.getRequired("values") + fun name(): String = name.getRequired("name") /** - * Returns the raw JSON value of [field]. + * Returns the raw JSON value of [id]. * - * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [operator]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("operator") + @JsonProperty("grouping_key") @ExcludeMissing - fun _operator(): JsonField = operator + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [values]. + * Returns the raw JSON value of [name]. * - * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -49778,83 +69772,74 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * Returns a mutable builder for constructing an instance of [LicenseType]. * * The following fields are required: * ```java - * .field() - * .operator() - * .values() + * .id() + * .groupingKey() + * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CompositePriceFilter]. */ + /** A builder for [LicenseType]. */ class Builder internal constructor() { - private var field: JsonField? = null - private var operator: JsonField? = null - private var values: JsonField>? = null + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(compositePriceFilter: CompositePriceFilter) = apply { - field = compositePriceFilter.field - operator = compositePriceFilter.operator - values = compositePriceFilter.values.map { it.toMutableList() } - additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() } - /** The property of the price to filter on. */ - fun field(field: Field) = field(JsonField.of(field)) + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.field] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.field] with a well-typed [Field] value instead. + * You should usually call [Builder.id] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun field(field: JsonField) = apply { this.field = field } - - /** Should prices that match the filter be included or excluded. */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) + fun id(id: JsonField) = apply { this.id = id } /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * The key used for grouping licenses of this type. This is typically a user + * identifier field. */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - /** The IDs or values that match this filter. */ - fun values(values: List) = values(JsonField.of(values)) + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.values] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.values] with a well-typed `List` value + * You should usually call [Builder.groupingKey] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun values(values: JsonField>) = apply { - this.values = values.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + /** - * Adds a single [String] to [values]. + * Sets [Builder.name] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addValue(value: String) = apply { - values = - (values ?: JsonField.of(mutableListOf())).also { - checkKnown("values", it).add(value) - } - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -49879,38 +69864,48 @@ private constructor( } /** - * Returns an immutable instance of [CompositePriceFilter]. + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .field() - * .operator() - * .values() + * .id() + * .groupingKey() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CompositePriceFilter = - CompositePriceFilter( - checkRequired("field", field), - checkRequired("operator", operator), - checkRequired("values", values).map { it.toImmutable() }, + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CompositePriceFilter = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { if (validated) { return@apply } - field().validate() - operator().validate() - values() + id() + groupingKey() + name() validated = true } @@ -49930,2514 +69925,3037 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (field.asKnown().getOrNull()?.validity() ?: 0) + - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (values.asKnown().getOrNull()?.size ?: 0) + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) - /** The property of the price to filter on. */ - class Field @JsonCreator private constructor(private val value: JsonField) : - Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } - @JvmField val PRICE_ID = of("price_id") + override fun hashCode(): Int = hashCode - @JvmField val ITEM_ID = of("item_id") + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } - @JvmField val PRICE_TYPE = of("price_type") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val CURRENCY = of("currency") + return other is GroupedWithProratedMinimum && + id == other.id && + billableMetric == other.billableMetric && + billingCycleConfiguration == other.billingCycleConfiguration && + billingMode == other.billingMode && + cadence == other.cadence && + compositePriceFilters == other.compositePriceFilters && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + createdAt == other.createdAt && + creditAllocation == other.creditAllocation && + currency == other.currency && + discount == other.discount && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + item == other.item && + maximum == other.maximum && + maximumAmount == other.maximumAmount && + metadata == other.metadata && + minimum == other.minimum && + minimumAmount == other.minimumAmount && + modelType == other.modelType && + name == other.name && + planPhaseOrder == other.planPhaseOrder && + priceType == other.priceType && + replacesPriceId == other.replacesPriceId && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && + additionalProperties == other.additionalProperties + } - @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + private val hashCode: Int by lazy { + Objects.hash( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedWithProratedMinimumConfig, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + licenseType, + additionalProperties, + ) + } - @JvmStatic fun of(value: String) = Field(JsonField.of(value)) - } + override fun hashCode(): Int = hashCode - /** An enum containing [Field]'s known values. */ - enum class Known { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - } + override fun toString() = + "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" + } - /** - * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Field] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - /** - * An enum member indicating that [Field] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + class GroupedWithMeteredMinimum + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val billableMetric: JsonField, + private val billingCycleConfiguration: JsonField, + private val billingMode: JsonField, + private val cadence: JsonField, + private val compositePriceFilters: JsonField>, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val createdAt: JsonField, + private val creditAllocation: JsonField, + private val currency: JsonField, + private val discount: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val groupedWithMeteredMinimumConfig: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val item: JsonField, + private val maximum: JsonField, + private val maximumAmount: JsonField, + private val metadata: JsonField, + private val minimum: JsonField, + private val minimumAmount: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val planPhaseOrder: JsonField, + private val priceType: JsonField, + private val replacesPriceId: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PRICE_ID -> Value.PRICE_ID - ITEM_ID -> Value.ITEM_ID - PRICE_TYPE -> Value.PRICE_TYPE - CURRENCY -> Value.CURRENCY - PRICING_UNIT_ID -> Value.PRICING_UNIT_ID - else -> Value._UNKNOWN - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("billing_mode") + @ExcludeMissing + billingMode: JsonField = JsonMissing.of(), + @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("composite_price_filters") + @ExcludeMissing + compositePriceFilters: JsonField> = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + priceType: JsonField = JsonMissing.of(), + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), + ) : this( + id, + billableMetric, + billingCycleConfiguration, + billingMode, + cadence, + compositePriceFilters, + conversionRate, + conversionRateConfig, + createdAt, + creditAllocation, + currency, + discount, + externalPriceId, + fixedPriceQuantity, + groupedWithMeteredMinimumConfig, + invoiceGroupingKey, + invoicingCycleConfiguration, + item, + maximum, + maximumAmount, + metadata, + minimum, + minimumAmount, + modelType, + name, + planPhaseOrder, + priceType, + replacesPriceId, + dimensionalPriceConfiguration, + licenseType, + mutableMapOf(), + ) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PRICE_ID -> Known.PRICE_ID - ITEM_ID -> Known.ITEM_ID - PRICE_TYPE -> Known.PRICE_TYPE - CURRENCY -> Known.CURRENCY - PRICING_UNIT_ID -> Known.PRICING_UNIT_ID - else -> throw OrbInvalidDataException("Unknown Field: $value") - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetric(): Optional = + billableMetric.getOptional("billable_metric") - private var validated: Boolean = false + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): BillingCycleConfiguration = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - fun validate(): Field = apply { - if (validated) { - return@apply - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") - known() - validated = true - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun compositePriceFilters(): Optional> = + compositePriceFilters.getOptional("composite_price_filters") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - return other is Field && value == other.value - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - override fun hashCode() = value.hashCode() + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditAllocation(): Optional = + creditAllocation.getOptional("credit_allocation") - override fun toString() = value.toString() - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun currency(): String = currency.getRequired("currency") - /** Should prices that match the filter be included or excluded. */ - class Operator @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discount(): Optional = discount.getOptional("discount") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") - companion object { + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - @JvmField val INCLUDES = of("includes") + /** + * Configuration for grouped_with_metered_minimum pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") - @JvmField val EXCLUDES = of("excludes") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - /** An enum containing [Operator]'s known values. */ - enum class Known { - INCLUDES, - EXCLUDES, - } + /** + * A minimal representation of an Item containing only the essential identifying + * information. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun item(): ItemSlim = item.getRequired("item") - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCLUDES, - EXCLUDES, - /** - * An enum member indicating that [Operator] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun maximum(): Optional = maximum.getOptional("maximum") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCLUDES -> Value.INCLUDES - EXCLUDES -> Value.EXCLUDES - else -> Value._UNKNOWN - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCLUDES -> Known.INCLUDES - EXCLUDES -> Known.EXCLUDES - else -> throw OrbInvalidDataException("Unknown Operator: $value") - } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun minimum(): Optional = minimum.getOptional("minimum") - private var validated: Boolean = false + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") - fun validate(): Operator = apply { - if (validated) { - return@apply - } + /** + * The pricing model type + * + * 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). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - known() - validated = true - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 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 priceType(): PriceType = priceType.getRequired("price_type") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The price id this price replaces. This price will take the place of the replaced price in + * plan version migrations. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") - return other is Operator && value == other.value - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - override fun hashCode() = value.hashCode() + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [billableMetric]. + * + * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - return other is CompositePriceFilter && - field == other.field && - operator == other.operator && - values == other.values && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - private val hashCode: Int by lazy { - Objects.hash(field, operator, values, additionalProperties) - } + /** + * Returns the raw JSON value of [billingMode]. + * + * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_mode") + @ExcludeMissing + fun _billingMode(): JsonField = billingMode - override fun hashCode(): Int = hashCode + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - override fun toString() = - "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" - } + /** + * Returns the raw JSON value of [compositePriceFilters]. + * + * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("composite_price_filters") + @ExcludeMissing + fun _compositePriceFilters(): JsonField> = compositePriceFilters - /** Configuration for grouped_allocation pricing */ - class GroupedAllocationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val allocation: JsonField, - private val groupingKey: JsonField, - private val overageUnitRate: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonCreator - private constructor( - @JsonProperty("allocation") - @ExcludeMissing - allocation: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("overage_unit_rate") - @ExcludeMissing - overageUnitRate: JsonField = JsonMissing.of(), - ) : this(allocation, groupingKey, overageUnitRate, mutableMapOf()) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Usage allocation per group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun allocation(): String = allocation.getRequired("allocation") + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - /** - * How to determine the groups that should each be allocated some quantity - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + /** + * Returns the raw JSON value of [creditAllocation]. + * + * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - /** - * Unit rate for post-allocation - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun overageUnitRate(): String = overageUnitRate.getRequired("overage_unit_rate") + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - /** - * Returns the raw JSON value of [allocation]. - * - * Unlike [allocation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation + /** + * Returns the raw JSON value of [discount]. + * + * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonField = discount - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns the raw JSON value of [overageUnitRate]. - * - * Unlike [overageUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("overage_unit_rate") - @ExcludeMissing - fun _overageUnitRate(): JsonField = overageUnitRate + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * + * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - companion object { + /** + * Returns the raw JSON value of [item]. + * + * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - /** - * Returns a mutable builder for constructing an instance of - * [GroupedAllocationConfig]. - * - * The following fields are required: - * ```java - * .allocation() - * .groupingKey() - * .overageUnitRate() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [maximum]. + * + * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum") + @ExcludeMissing + fun _maximum(): JsonField = maximum - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - private var allocation: JsonField? = null - private var groupingKey: JsonField? = null - private var overageUnitRate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { - allocation = groupedAllocationConfig.allocation - groupingKey = groupedAllocationConfig.groupingKey - overageUnitRate = groupedAllocationConfig.overageUnitRate - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [minimum]. + * + * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum") + @ExcludeMissing + fun _minimum(): JsonField = minimum - /** Usage allocation per group */ - fun allocation(allocation: String) = allocation(JsonField.of(allocation)) + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - /** - * Sets [Builder.allocation] to an arbitrary JSON value. - * - * You should usually call [Builder.allocation] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** How to determine the groups that should each be allocated some quantity */ - fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + /** + * Returns the raw JSON value of [planPhaseOrder]. + * + * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + /** + * Returns the raw JSON value of [priceType]. + * + * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - /** Unit rate for post-allocation */ - fun overageUnitRate(overageUnitRate: String) = - overageUnitRate(JsonField.of(overageUnitRate)) + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Sets [Builder.overageUnitRate] to an arbitrary JSON value. - * - * You should usually call [Builder.overageUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun overageUnitRate(overageUnitRate: JsonField) = apply { - this.overageUnitRate = overageUnitRate - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [GroupedAllocationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .allocation() - * .groupingKey() - * .overageUnitRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig( - checkRequired("allocation", allocation), - checkRequired("groupingKey", groupingKey), - checkRequired("overageUnitRate", overageUnitRate), - additionalProperties.toMutableMap(), - ) - } + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimum]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedWithMeteredMinimumConfig() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [GroupedWithMeteredMinimum]. */ + class Builder internal constructor() { - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var billingMode: JsonField? = null + private var cadence: JsonField? = null + private var compositePriceFilters: JsonField>? = null + private var conversionRate: JsonField? = null + private var conversionRateConfig: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var invoiceGroupingKey: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_with_metered_minimum") + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var replacesPriceId: JsonField? = null + private var dimensionalPriceConfiguration: JsonField = + JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - allocation() - groupingKey() - overageUnitRate() - validated = true + @JvmSynthetic + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { + id = groupedWithMeteredMinimum.id + billableMetric = groupedWithMeteredMinimum.billableMetric + billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration + billingMode = groupedWithMeteredMinimum.billingMode + cadence = groupedWithMeteredMinimum.cadence + compositePriceFilters = + groupedWithMeteredMinimum.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedWithMeteredMinimum.conversionRate + conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig + createdAt = groupedWithMeteredMinimum.createdAt + creditAllocation = groupedWithMeteredMinimum.creditAllocation + currency = groupedWithMeteredMinimum.currency + discount = groupedWithMeteredMinimum.discount + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = groupedWithMeteredMinimum.invoicingCycleConfiguration + item = groupedWithMeteredMinimum.item + maximum = groupedWithMeteredMinimum.maximum + maximumAmount = groupedWithMeteredMinimum.maximumAmount + metadata = groupedWithMeteredMinimum.metadata + minimum = groupedWithMeteredMinimum.minimum + minimumAmount = groupedWithMeteredMinimum.minimumAmount + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + planPhaseOrder = groupedWithMeteredMinimum.planPhaseOrder + priceType = groupedWithMeteredMinimum.priceType + replacesPriceId = groupedWithMeteredMinimum.replacesPriceId + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + licenseType = groupedWithMeteredMinimum.licenseType + additionalProperties = groupedWithMeteredMinimum.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun id(id: String) = id(JsonField.of(id)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.id] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - @JvmSynthetic - internal fun validity(): Int = - (if (allocation.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (overageUnitRate.asKnown().isPresent) 1 else 0) + fun id(id: JsonField) = apply { this.id = id } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) - return other is GroupedAllocationConfig && - allocation == other.allocation && - groupingKey == other.groupingKey && - overageUnitRate == other.overageUnitRate && - additionalProperties == other.additionalProperties - } + /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.getOrNull()) - private val hashCode: Int by lazy { - Objects.hash(allocation, groupingKey, overageUnitRate, additionalProperties) + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric } - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedAllocationConfig{allocation=$allocation, groupingKey=$groupingKey, overageUnitRate=$overageUnitRate, additionalProperties=$additionalProperties}" - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - companion object { + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode } - /** 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 cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } } - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true + /** + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Alias for [Builder.conversionRate]. * - * Used for best match union deserialization. + * This unboxed primitive overload exists for backwards compatibility. */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - return other is Metadata && additionalProperties == other.additionalProperties + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) /** - * Returns this class instance's raw value. + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } - @JvmField val USAGE_PRICE = of("usage_price") + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - @JvmField val FIXED_PRICE = of("fixed_price") + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) - @JvmField val COMPOSITE_PRICE = of("composite_price") + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * Sets [Builder.createdAt] to an arbitrary JSON value. * - * 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. + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt } + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.getOrNull()) /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * Sets [Builder.creditAllocation] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Sets [Builder.currency] to an arbitrary JSON value. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } + fun currency(currency: JsonField) = apply { this.currency = currency } - known() - validated = true - } + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ + @Deprecated("deprecated") + fun discount(discount: Optional) = discount(discount.getOrNull()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.discount] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } - return other is PriceType && value == other.value - } + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - override fun hashCode() = value.hashCode() + /** + * Alias for calling [discount] with the following: + * ```java + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) - override fun toString() = value.toString() - } + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) - return other is GroupedAllocation && - id == other.id && - billableMetric == other.billableMetric && - billingCycleConfiguration == other.billingCycleConfiguration && - billingMode == other.billingMode && - cadence == other.cadence && - compositePriceFilters == other.compositePriceFilters && - conversionRate == other.conversionRate && - conversionRateConfig == other.conversionRateConfig && - createdAt == other.createdAt && - creditAllocation == other.creditAllocation && - currency == other.currency && - discount == other.discount && - externalPriceId == other.externalPriceId && - fixedPriceQuantity == other.fixedPriceQuantity && - groupedAllocationConfig == other.groupedAllocationConfig && - invoicingCycleConfiguration == other.invoicingCycleConfiguration && - item == other.item && - maximum == other.maximum && - maximumAmount == other.maximumAmount && - metadata == other.metadata && - minimum == other.minimum && - minimumAmount == other.minimumAmount && - modelType == other.modelType && - name == other.name && - planPhaseOrder == other.planPhaseOrder && - priceType == other.priceType && - replacesPriceId == other.replacesPriceId && - dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [discount] with the following: + * ```java + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) - private val hashCode: Int by lazy { - Objects.hash( - id, - billableMetric, - billingCycleConfiguration, - billingMode, - cadence, - compositePriceFilters, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - groupedAllocationConfig, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - dimensionalPriceConfiguration, - additionalProperties, - ) - } + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - override fun hashCode(): Int = hashCode + /** + * Alias for calling [discount] with the following: + * ```java + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) - override fun toString() = - "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - class BulkWithProration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val billableMetric: JsonField, - private val billingCycleConfiguration: JsonField, - private val billingMode: JsonField, - private val bulkWithProrationConfig: JsonField, - private val cadence: JsonField, - private val compositePriceFilters: JsonField>, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val createdAt: JsonField, - private val creditAllocation: JsonField, - private val currency: JsonField, - private val discount: JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val item: JsonField, - private val maximum: JsonField, - private val maximumAmount: JsonField, - private val metadata: JsonField, - private val minimum: JsonField, - private val minimumAmount: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val planPhaseOrder: JsonField, - private val priceType: JsonField, - private val replacesPriceId: JsonField, - private val dimensionalPriceConfiguration: JsonField, - private val additionalProperties: MutableMap, - ) { + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("billing_mode") - @ExcludeMissing - billingMode: JsonField = JsonMissing.of(), - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - bulkWithProrationConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("composite_price_filters") - @ExcludeMissing - compositePriceFilters: JsonField> = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - priceType: JsonField = JsonMissing.of(), - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - ) : this( - id, - billableMetric, - billingCycleConfiguration, - billingMode, - bulkWithProrationConfig, - cadence, - compositePriceFilters, - conversionRate, - conversionRateConfig, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - replacesPriceId, - dimensionalPriceConfiguration, - mutableMapOf(), - ) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun billableMetric(): Optional = - billableMetric.getOptional("billable_metric") + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun billingMode(): BillingMode = billingMode.getRequired("billing_mode") + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Configuration for bulk_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") + /** Configuration for grouped_with_metered_minimum pricing */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a well-typed + * [GroupedWithMeteredMinimumConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun compositePriceFilters(): Optional> = - compositePriceFilters.getOptional("composite_price_filters") + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun creditAllocation(): Optional = - creditAllocation.getOptional("credit_allocation") + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun currency(): String = currency.getRequired("currency") + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discount(): Optional = discount.getOptional("discount") + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + /** + * Sets [Builder.item] to an arbitrary JSON value. + * + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ + @Deprecated("deprecated") + fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) - /** - * A minimal representation of an Item containing only the essential identifying - * information. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun item(): ItemSlim = item.getRequired("item") + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun maximum(): Optional = maximum.getOptional("maximum") + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun minimum(): Optional = minimum.getOptional("minimum") + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * The pricing model type - * - * 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). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") + /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ + @Deprecated("deprecated") + fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun planPhaseOrder(): Optional = planPhaseOrder.getOptional("plan_phase_order") + /** + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun priceType(): PriceType = priceType.getRequired("price_type") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * The price id this price replaces. This price will take the place of the replaced price in - * plan version migrations. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") + fun name(name: String) = name(JsonField.of(name)) - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - /** - * Returns the raw JSON value of [billableMetric]. - * - * Unlike [billableMetric], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + /** + * Alias for [Builder.planPhaseOrder]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) - /** - * Returns the raw JSON value of [billingMode]. - * - * Unlike [billingMode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("billing_mode") - @ExcludeMissing - fun _billingMode(): JsonField = billingMode + /** + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - /** - * Returns the raw JSON value of [bulkWithProrationConfig]. - * - * Unlike [bulkWithProrationConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - /** - * Returns the raw JSON value of [compositePriceFilters]. - * - * Unlike [compositePriceFilters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("composite_price_filters") - @ExcludeMissing - fun _compositePriceFilters(): JsonField> = compositePriceFilters + /** + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ + fun replacesPriceId(replacesPriceId: Optional) = + replacesPriceId(replacesPriceId.getOrNull()) - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - /** - * Returns the raw JSON value of [creditAllocation]. - * - * Unlike [creditAllocation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - /** - * Returns the raw JSON value of [discount]. - * - * Unlike [discount], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discount") - @ExcludeMissing - fun _discount(): JsonField = discount + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [item]. - * - * Unlike [item], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [maximum]. - * - * Unlike [maximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw JSON value of [minimum]. - * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum + /** + * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedWithMeteredMinimumConfig() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + dimensionalPriceConfiguration, + licenseType, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + private var validated: Boolean = false /** - * Returns the raw JSON value of [name]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [planPhaseOrder]. + * This method is _not_ forwards compatible with new types from the API for existing fields. * - * Unlike [planPhaseOrder], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + fun validate(): GroupedWithMeteredMinimum = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [priceType]. - * - * Unlike [priceType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + billingMode().validate() + cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + groupedWithMeteredMinimumConfig().validate() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } + validated = true + } - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field has - * an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) - companion object { + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns a mutable builder for constructing an instance of [BulkWithProration]. + * Returns this class instance's raw value. * - * The following fields are required: - * ```java - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .billingMode() - * .bulkWithProrationConfig() - * .cadence() - * .compositePriceFilters() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * ``` + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JvmStatic fun builder() = Builder() - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** A builder for [BulkWithProration]. */ - class Builder internal constructor() { + companion object { - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var billingMode: JsonField? = null - private var bulkWithProrationConfig: JsonField? = null - private var cadence: JsonField? = null - private var compositePriceFilters: JsonField>? = null - private var conversionRate: JsonField? = null - private var conversionRateConfig: JsonField? = null - private var createdAt: JsonField? = null - private var creditAllocation: JsonField? = null - private var currency: JsonField? = null - private var discount: JsonField? = null - private var externalPriceId: JsonField? = null - private var fixedPriceQuantity: JsonField? = null - private var invoicingCycleConfiguration: JsonField? = null - private var item: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var metadata: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_proration") - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var replacesPriceId: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val IN_ADVANCE = of("in_advance") - @JvmSynthetic - internal fun from(bulkWithProration: BulkWithProration) = apply { - id = bulkWithProration.id - billableMetric = bulkWithProration.billableMetric - billingCycleConfiguration = bulkWithProration.billingCycleConfiguration - billingMode = bulkWithProration.billingMode - bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig - cadence = bulkWithProration.cadence - compositePriceFilters = - bulkWithProration.compositePriceFilters.map { it.toMutableList() } - conversionRate = bulkWithProration.conversionRate - conversionRateConfig = bulkWithProration.conversionRateConfig - createdAt = bulkWithProration.createdAt - creditAllocation = bulkWithProration.creditAllocation - currency = bulkWithProration.currency - discount = bulkWithProration.discount - externalPriceId = bulkWithProration.externalPriceId - fixedPriceQuantity = bulkWithProration.fixedPriceQuantity - invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration - item = bulkWithProration.item - maximum = bulkWithProration.maximum - maximumAmount = bulkWithProration.maximumAmount - metadata = bulkWithProration.metadata - minimum = bulkWithProration.minimum - minimumAmount = bulkWithProration.minimumAmount - modelType = bulkWithProration.modelType - name = bulkWithProration.name - planPhaseOrder = bulkWithProration.planPhaseOrder - priceType = bulkWithProration.priceType - replacesPriceId = bulkWithProration.replacesPriceId - dimensionalPriceConfiguration = bulkWithProration.dimensionalPriceConfiguration - additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - fun id(id: String) = id(JsonField.of(id)) + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } /** - * Sets [Builder.id] to an arbitrary JSON value. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetricTiny?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.getOrNull()) + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * Sets [Builder.billableMetric] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.billableMetric] with a well-typed - * [BillableMetricTiny] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + private var validated: Boolean = false /** - * Sets [Builder.billingMode] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun billingMode(billingMode: JsonField) = apply { - this.billingMode = billingMode + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true } - /** Configuration for bulk_with_proration pricing */ - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.bulkWithProrationConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.bulkWithProrationConfig] with a well-typed - * [BulkWithProrationConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * Returns this class instance's raw value. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun compositePriceFilters(compositePriceFilters: List?) = - compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + companion object { - /** - * Alias for calling [Builder.compositePriceFilters] with - * `compositePriceFilters.orElse(null)`. - */ - fun compositePriceFilters(compositePriceFilters: Optional>) = - compositePriceFilters(compositePriceFilters.getOrNull()) + @JvmField val ONE_TIME = of("one_time") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } /** - * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun compositePriceFilters( - compositePriceFilters: JsonField> - ) = apply { - this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, } /** - * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { - compositePriceFilters = - (compositePriceFilters ?: JsonField.of(mutableListOf())).also { - checkKnown("compositePriceFilters", it).add(compositePriceFilter) - } - } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } /** - * Alias for [Builder.conversionRate]. + * Returns an enum member corresponding to this class instance's value. * - * This unboxed primitive overload exists for backwards compatibility. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + private var validated: Boolean = false /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun conversionRateConfig(conversionRateConfig: JsonField) = - apply { - this.conversionRateConfig = conversionRateConfig + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + return other is Cadence && value == other.value + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) + override fun hashCode() = value.hashCode() - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + override fun toString() = value.toString() + } - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() - ) + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) + + /** + * The property of the price to filter on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun field(): Field = field.getRequired("field") /** - * Sets [Builder.createdAt] to an arbitrary JSON value. + * Should prices that match the filter be included or excluded. * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: Allocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) + fun operator(): Operator = operator.getRequired("operator") /** - * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. + * The IDs or values that match this filter. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.getOrNull()) + fun values(): List = values.getRequired("values") /** - * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * Returns the raw JSON value of [field]. * - * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. */ - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field /** - * Sets [Builder.currency] to an arbitrary JSON value. + * Returns the raw JSON value of [operator]. * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ - @Deprecated("deprecated") - fun discount(discount: Optional) = discount(discount.getOrNull()) + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator /** - * Sets [Builder.discount] to an arbitrary JSON value. + * Returns the raw JSON value of [values]. * - * You should usually call [Builder.discount] with a well-typed [Discount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Alias for calling [discount] with the following: - * ```java - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + fun toBuilder() = Builder().from(this) - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + companion object { - /** - * Alias for calling [discount] with the following: - * ```java - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { - /** - * Alias for calling [discount] with the following: - * ```java - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + @JvmSynthetic + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + private var validated: Boolean = false /** - * Alias for [Builder.fixedPriceQuantity]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + field().validate() + operator().validate() + values() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + @JvmSynthetic + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: BillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + companion object { - /** - * A minimal representation of an Item containing only the essential identifying - * information. - */ - fun item(item: ItemSlim) = item(JsonField.of(item)) + @JvmField val PRICE_ID = of("price_id") - /** - * Sets [Builder.item] to an arbitrary JSON value. - * - * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun item(item: JsonField) = apply { this.item = item } + @JvmField val ITEM_ID = of("item_id") - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + @JvmField val PRICE_TYPE = of("price_type") - /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ - @Deprecated("deprecated") - fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + @JvmField val CURRENCY = of("currency") - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Field = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and - * the entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + return other is Field && value == other.value + } - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + override fun hashCode() = value.hashCode() - /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ - @Deprecated("deprecated") - fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + override fun toString() = value.toString() + } - /** - * Sets [Builder.minimum] to an arbitrary JSON value. - * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.getOrNull()) + companion object { - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + @JvmField val INCLUDES = of("includes") - /** - * 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("bulk_with_proration") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + @JvmField val EXCLUDES = of("excludes") - fun name(name: String) = name(JsonField.of(name)) + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Alias for [Builder.planPhaseOrder]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + private var validated: Boolean = false - /** - * Sets [Builder.priceType] to an arbitrary JSON value. - * - * You should usually call [Builder.priceType] with a well-typed [PriceType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } - /** - * The price id this price replaces. This price will take the place of the replaced - * price in plan version migrations. - */ - fun replacesPriceId(replacesPriceId: String?) = - replacesPriceId(JsonField.ofNullable(replacesPriceId)) + known() + validated = true + } - /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ - fun replacesPriceId(replacesPriceId: Optional) = - replacesPriceId(replacesPriceId.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + return other is Operator && value == other.value + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [DimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + override fun hashCode() = value.hashCode() - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + override fun toString() = value.toString() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) } - /** - * Returns an immutable instance of [BulkWithProration]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .billingMode() - * .bulkWithProrationConfig() - * .cadence() - * .compositePriceFilters() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithProration = - BulkWithProration( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("billingMode", billingMode), - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), - checkRequired("cadence", cadence), - checkRequired("compositePriceFilters", compositePriceFilters).map { - it.toImmutable() - }, - checkRequired("conversionRate", conversionRate), - checkRequired("conversionRateConfig", conversionRateConfig), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - modelType, - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("replacesPriceId", replacesPriceId), - dimensionalPriceConfiguration, - additionalProperties.toMutableMap(), - ) + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - private var validated: Boolean = false + /** Configuration for grouped_with_metered_minimum pricing */ + class GroupedWithMeteredMinimumConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val minimumUnitAmount: JsonField, + private val pricingKey: JsonField, + private val scalingFactors: JsonField>, + private val scalingKey: JsonField, + private val unitAmounts: JsonField>, + private val additionalProperties: MutableMap, + ) { - fun validate(): BulkWithProration = apply { - if (validated) { - return@apply - } + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + minimumUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("pricing_key") + @ExcludeMissing + pricingKey: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factors") + @ExcludeMissing + scalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("scaling_key") + @ExcludeMissing + scalingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amounts") + @ExcludeMissing + unitAmounts: JsonField> = JsonMissing.of(), + ) : this( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + mutableMapOf(), + ) - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - billingMode().validate() - bulkWithProrationConfig().validate() - cadence().validate() - compositePriceFilters().ifPresent { it.forEach { it.validate() } } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - createdAt() - creditAllocation().ifPresent { it.validate() } - currency() - discount().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoicingCycleConfiguration().ifPresent { it.validate() } - item().validate() - maximum().ifPresent { it.validate() } - maximumAmount() - metadata().validate() - minimum().ifPresent { it.validate() } - minimumAmount() - _modelType().let { - if (it != JsonValue.from("bulk_with_proration")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - planPhaseOrder() - priceType().validate() - replacesPriceId() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } + /** + * Used to partition the usage into groups. The minimum amount is applied to each group. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The minimum amount to charge per group per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumUnitAmount(): String = minimumUnitAmount.getRequired("minimum_unit_amount") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (billingMode.asKnown().getOrNull()?.validity() ?: 0) + - (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (discount.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (item.asKnown().getOrNull()?.validity() ?: 0) + - (maximum.asKnown().getOrNull()?.validity() ?: 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (minimum.asKnown().getOrNull()?.validity() ?: 0) + - (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (priceType.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + /** + * Used to determine the unit rate + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun pricingKey(): String = pricingKey.getRequired("pricing_key") - class BillingMode @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Scale the unit rates by the scaling factor. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactors(): List = + scalingFactors.getRequired("scaling_factors") /** - * Returns this class instance's raw value. + * Used to determine the unit rate scaling factor * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val IN_ADVANCE = of("in_advance") - - @JvmField val IN_ARREAR = of("in_arrear") - - @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) - } + fun scalingKey(): String = scalingKey.getRequired("scaling_key") - /** An enum containing [BillingMode]'s known values. */ - enum class Known { - IN_ADVANCE, - IN_ARREAR, - } + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any + * unmatched usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") /** - * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. + * Returns the raw JSON value of [groupingKey]. * - * An instance of [BillingMode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. */ - enum class Value { - IN_ADVANCE, - IN_ARREAR, - /** - * An enum member indicating that [BillingMode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Returns the raw JSON value of [minimumUnitAmount]. * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. + * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun value(): Value = - when (this) { - IN_ADVANCE -> Value.IN_ADVANCE - IN_ARREAR -> Value.IN_ARREAR - else -> Value._UNKNOWN - } + @JsonProperty("minimum_unit_amount") + @ExcludeMissing + fun _minimumUnitAmount(): JsonField = minimumUnitAmount /** - * Returns an enum member corresponding to this class instance's value. + * Returns the raw JSON value of [pricingKey]. * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * Unlike [pricingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pricing_key") + @ExcludeMissing + fun _pricingKey(): JsonField = pricingKey + + /** + * Returns the raw JSON value of [scalingFactors]. * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. + * Unlike [scalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun known(): Known = - when (this) { - IN_ADVANCE -> Known.IN_ADVANCE - IN_ARREAR -> Known.IN_ARREAR - else -> throw OrbInvalidDataException("Unknown BillingMode: $value") - } + @JsonProperty("scaling_factors") + @ExcludeMissing + fun _scalingFactors(): JsonField> = scalingFactors /** - * Returns this class instance's primitive wire representation. + * Returns the raw JSON value of [scalingKey]. * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Unlike [scalingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scaling_key") + @ExcludeMissing + fun _scalingKey(): JsonField = scalingKey + + /** + * Returns the raw JSON value of [unitAmounts]. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + @JsonProperty("unit_amounts") + @ExcludeMissing + fun _unitAmounts(): JsonField> = unitAmounts + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var minimumUnitAmount: JsonField? = null + private var pricingKey: JsonField? = null + private var scalingFactors: JsonField>? = null + private var scalingKey: JsonField? = null + private var unitAmounts: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = apply { + groupingKey = groupedWithMeteredMinimumConfig.groupingKey + minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount + pricingKey = groupedWithMeteredMinimumConfig.pricingKey + scalingFactors = + groupedWithMeteredMinimumConfig.scalingFactors.map { it.toMutableList() } + scalingKey = groupedWithMeteredMinimumConfig.scalingKey + unitAmounts = + groupedWithMeteredMinimumConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() + } + + /** + * Used to partition the usage into groups. The minimum amount is applied to each + * group. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The minimum amount to charge per group per unit */ + fun minimumUnitAmount(minimumUnitAmount: String) = + minimumUnitAmount(JsonField.of(minimumUnitAmount)) + + /** + * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumUnitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { + this.minimumUnitAmount = minimumUnitAmount + } + + /** Used to determine the unit rate */ + fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) + + /** + * Sets [Builder.pricingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun pricingKey(pricingKey: JsonField) = apply { + this.pricingKey = pricingKey + } + + /** Scale the unit rates by the scaling factor. */ + fun scalingFactors(scalingFactors: List) = + scalingFactors(JsonField.of(scalingFactors)) + + /** + * Sets [Builder.scalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scalingFactors(scalingFactors: JsonField>) = apply { + this.scalingFactors = scalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [ScalingFactor] to [scalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addScalingFactor(scalingFactor: ScalingFactor) = apply { + scalingFactors = + (scalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("scalingFactors", it).add(scalingFactor) + } + } + + /** Used to determine the unit rate scaling factor */ + fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + + /** + * Sets [Builder.scalingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun scalingKey(scalingKey: JsonField) = apply { + this.scalingKey = scalingKey + } + + /** + * Apply per unit pricing to each pricing value. The minimum amount is applied any + * unmatched usage. + */ + fun unitAmounts(unitAmounts: List) = + unitAmounts(JsonField.of(unitAmounts)) + + /** + * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmounts] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun unitAmounts(unitAmounts: JsonField>) = apply { + this.unitAmounts = unitAmounts.map { it.toMutableList() } + } + + /** + * Adds a single [UnitAmount] to [unitAmounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUnitAmount(unitAmount: UnitAmount) = apply { + unitAmounts = + (unitAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("unitAmounts", it).add(unitAmount) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .minimumUnitAmount() + * .pricingKey() + * .scalingFactors() + * .scalingKey() + * .unitAmounts() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMeteredMinimumConfig = + GroupedWithMeteredMinimumConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("minimumUnitAmount", minimumUnitAmount), + checkRequired("pricingKey", pricingKey), + checkRequired("scalingFactors", scalingFactors).map { it.toImmutable() }, + checkRequired("scalingKey", scalingKey), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } private var validated: Boolean = false - fun validate(): BillingMode = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedWithMeteredMinimumConfig = apply { if (validated) { return@apply } - known() + groupingKey() + minimumUnitAmount() + pricingKey() + scalingFactors().forEach { it.validate() } + scalingKey() + unitAmounts().forEach { it.validate() } validated = true } @@ -52455,243 +72973,295 @@ 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 = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + + (if (pricingKey.asKnown().isPresent) 1 else 0) + + (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (scalingKey.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Configuration for a scaling factor */ + class ScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scalingFactor: JsonField, + private val scalingValue: JsonField, + private val additionalProperties: MutableMap, + ) { - return other is BillingMode && value == other.value - } + @JsonCreator + private constructor( + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("scaling_value") + @ExcludeMissing + scalingValue: JsonField = JsonMissing.of(), + ) : this(scalingFactor, scalingValue, mutableMapOf()) - override fun hashCode() = value.hashCode() + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") - override fun toString() = value.toString() - } + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingValue(): String = scalingValue.getRequired("scaling_value") - /** Configuration for bulk_with_proration pricing */ - class BulkWithProrationConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor - @JsonCreator - private constructor( - @JsonProperty("tiers") + /** + * Returns the raw JSON value of [scalingValue]. + * + * Unlike [scalingValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_value") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + fun _scalingValue(): JsonField = scalingValue - /** - * Bulk tiers for rating based on total usage volume - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tiers(): List = tiers.getRequired("tiers") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ScalingFactor]. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalingFactor]. */ + class Builder internal constructor() { + + private var scalingFactor: JsonField? = null + private var scalingValue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scalingFactor: ScalingFactor) = apply { + this.scalingFactor = scalingFactor.scalingFactor + scalingValue = scalingFactor.scalingValue + additionalProperties = scalingFactor.additionalProperties.toMutableMap() + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun scalingValue(scalingValue: String) = + scalingValue(JsonField.of(scalingValue)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.scalingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingValue(scalingValue: JsonField) = apply { + this.scalingValue = scalingValue + } - fun toBuilder() = Builder().from(this) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - companion object { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithProrationConfig]. - * - * The following fields are required: - * ```java - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { - tiers = bulkWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() + /** + * Returns an immutable instance of [ScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .scalingFactor() + * .scalingValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalingFactor = + ScalingFactor( + checkRequired("scalingFactor", scalingFactor), + checkRequired("scalingValue", scalingValue), + additionalProperties.toMutableMap(), + ) } - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + private var validated: Boolean = false /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.tiers] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Adds a single [Tier] to [tiers]. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): ScalingFactor = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + scalingFactor() + scalingValue() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [BulkWithProrationConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tiers() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (scalingValue.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply + return other is ScalingFactor && + scalingFactor == other.scalingFactor && + scalingValue == other.scalingValue && + additionalProperties == other.additionalProperties } - tiers().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(scalingFactor, scalingValue, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun hashCode(): Int = hashCode - /** Configuration for a single bulk pricing tier with proration */ - class Tier + override fun toString() = + "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a unit amount */ + class UnitAmount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val pricingValue: JsonField, private val unitAmount: JsonField, - private val tierLowerBound: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("pricing_value") + @ExcludeMissing + pricingValue: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + ) : this(pricingValue, unitAmount, mutableMapOf()) /** - * Cost per unit - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun pricingValue(): String = pricingValue.getRequired("pricing_value") /** - * The lower bound for this tier + * Per unit amount * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") + fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [pricingValue]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * Unlike [pricingValue], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_amount") + @JsonProperty("pricing_value") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _pricingValue(): JsonField = pricingValue /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns the raw JSON value of [unitAmount]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * Unlike [unitAmount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("unit_amount") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -52708,31 +73278,46 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tier]. + * Returns a mutable builder for constructing an instance of [UnitAmount]. * * The following fields are required: * ```java + * .pricingValue() * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Tier]. */ + /** A builder for [UnitAmount]. */ class Builder internal constructor() { + private var pricingValue: JsonField? = null private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() + internal fun from(unitAmount: UnitAmount) = apply { + pricingValue = unitAmount.pricingValue + this.unitAmount = unitAmount.unitAmount + additionalProperties = unitAmount.additionalProperties.toMutableMap() } - /** Cost per unit */ + fun pricingValue(pricingValue: String) = + pricingValue(JsonField.of(pricingValue)) + + /** + * Sets [Builder.pricingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.pricingValue] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun pricingValue(pricingValue: JsonField) = apply { + this.pricingValue = pricingValue + } + + /** Per unit amount */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -52746,28 +73331,6 @@ private constructor( this.unitAmount = unitAmount } - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) - - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -52791,34 +73354,45 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [UnitAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java + * .pricingValue() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( + fun build(): UnitAmount = + UnitAmount( + checkRequired("pricingValue", pricingValue), checkRequired("unitAmount", unitAmount), - tierLowerBound, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Tier = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): UnitAmount = apply { if (validated) { return@apply } + pricingValue() unitAmount() - tierLowerBound() validated = true } @@ -52838,28 +73412,28 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + (if (pricingValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Tier && + return other is UnitAmount && + pricingValue == other.pricingValue && unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) + Objects.hash(pricingValue, unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -52867,20 +73441,152 @@ private constructor( return true } - return other is BulkWithProrationConfig && - tiers == other.tiers && + return other is GroupedWithMeteredMinimumConfig && + groupingKey == other.groupingKey && + minimumUnitAmount == other.minimumUnitAmount && + pricingKey == other.pricingKey && + scalingFactors == other.scalingFactors && + scalingKey == other.scalingKey && + unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + minimumUnitAmount, + pricingKey, + scalingFactors, + scalingKey, + unitAmounts, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } - class Cadence @JsonCreator private constructor(private val value: JsonField) : + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -52895,49 +73601,38 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") + @JvmField val USAGE_PRICE = of("usage_price") - @JvmField val ANNUAL = of("annual") + @JvmField val FIXED_PRICE = of("fixed_price") - @JvmField val CUSTOM = of("custom") + @JvmField val COMPOSITE_PRICE = of("composite_price") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [PriceType]'s known values. */ enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, } /** - * An enum containing [Cadence]'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 [Cadence] 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 { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -52951,12 +73646,9 @@ private constructor( */ fun value(): Value = when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE else -> Value._UNKNOWN } @@ -52971,13 +73663,10 @@ private constructor( */ fun known(): Known = when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } /** @@ -52994,7 +73683,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Cadence = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { if (validated) { return@apply } @@ -53024,7 +73723,7 @@ private constructor( return true } - return other is Cadence && value == other.value + return other is PriceType && value == other.value } override fun hashCode() = value.hashCode() @@ -53032,76 +73731,79 @@ private constructor( override fun toString() = value.toString() } - class CompositePriceFilter + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val field: JsonField, - private val operator: JsonField, - private val values: JsonField>, + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("values") + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") @ExcludeMissing - values: JsonField> = JsonMissing.of(), - ) : this(field, operator, values, mutableMapOf()) + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) /** - * The property of the price to filter on. + * The Orb-assigned unique identifier for the license type. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun field(): Field = field.getRequired("field") + fun id(): String = id.getRequired("id") /** - * Should prices that match the filter be included or excluded. + * The key used for grouping licenses of this type. This is typically a user identifier + * field. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun operator(): Operator = operator.getRequired("operator") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The IDs or values that match this filter. + * The name of the license type. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun values(): List = values.getRequired("values") + fun name(): String = name.getRequired("name") /** - * Returns the raw JSON value of [field]. + * Returns the raw JSON value of [id]. * - * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [operator]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("operator") + @JsonProperty("grouping_key") @ExcludeMissing - fun _operator(): JsonField = operator + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [values]. + * Returns the raw JSON value of [name]. * - * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -53118,499 +73820,74 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * Returns a mutable builder for constructing an instance of [LicenseType]. * * The following fields are required: * ```java - * .field() - * .operator() - * .values() + * .id() + * .groupingKey() + * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CompositePriceFilter]. */ + /** A builder for [LicenseType]. */ class Builder internal constructor() { - private var field: JsonField? = null - private var operator: JsonField? = null - private var values: JsonField>? = null + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(compositePriceFilter: CompositePriceFilter) = apply { - field = compositePriceFilter.field - operator = compositePriceFilter.operator - values = compositePriceFilter.values.map { it.toMutableList() } - additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() } - /** The property of the price to filter on. */ - fun field(field: Field) = field(JsonField.of(field)) + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.field] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.field] with a well-typed [Field] value instead. + * You should usually call [Builder.id] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun field(field: JsonField) = apply { this.field = field } - - /** Should prices that match the filter be included or excluded. */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) + fun id(id: JsonField) = apply { this.id = id } /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * The key used for grouping licenses of this type. This is typically a user + * identifier field. */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - /** The IDs or values that match this filter. */ - fun values(values: List) = values(JsonField.of(values)) + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.values] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.values] with a well-typed `List` value + * You should usually call [Builder.groupingKey] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun values(values: JsonField>) = apply { - this.values = values.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [values]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addValue(value: String) = apply { - values = - (values ?: JsonField.of(mutableListOf())).also { - checkKnown("values", it).add(value) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CompositePriceFilter]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .field() - * .operator() - * .values() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CompositePriceFilter = - CompositePriceFilter( - checkRequired("field", field), - checkRequired("operator", operator), - checkRequired("values", values).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CompositePriceFilter = apply { - if (validated) { - return@apply - } - - field().validate() - operator().validate() - values() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (field.asKnown().getOrNull()?.validity() ?: 0) + - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (values.asKnown().getOrNull()?.size ?: 0) - - /** The property of the price to filter on. */ - class Field @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PRICE_ID = of("price_id") - - @JvmField val ITEM_ID = of("item_id") - - @JvmField val PRICE_TYPE = of("price_type") - - @JvmField val CURRENCY = of("currency") - - @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") - - @JvmStatic fun of(value: String) = Field(JsonField.of(value)) - } - - /** An enum containing [Field]'s known values. */ - enum class Known { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - } - - /** - * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Field] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - /** - * An enum member indicating that [Field] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PRICE_ID -> Value.PRICE_ID - ITEM_ID -> Value.ITEM_ID - PRICE_TYPE -> Value.PRICE_TYPE - CURRENCY -> Value.CURRENCY - PRICING_UNIT_ID -> Value.PRICING_UNIT_ID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PRICE_ID -> Known.PRICE_ID - ITEM_ID -> Known.ITEM_ID - PRICE_TYPE -> Known.PRICE_TYPE - CURRENCY -> Known.CURRENCY - PRICING_UNIT_ID -> Known.PRICING_UNIT_ID - else -> throw OrbInvalidDataException("Unknown Field: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Field = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Field && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Should prices that match the filter be included or excluded. */ - class Operator @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INCLUDES = of("includes") - - @JvmField val EXCLUDES = of("excludes") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - INCLUDES, - EXCLUDES, - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCLUDES, - EXCLUDES, - /** - * An enum member indicating that [Operator] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCLUDES -> Value.INCLUDES - EXCLUDES -> Value.EXCLUDES - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCLUDES -> Known.INCLUDES - EXCLUDES -> Known.EXCLUDES - else -> throw OrbInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.name] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CompositePriceFilter && - field == other.field && - operator == other.operator && - values == other.values && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, operator, values, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * 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 name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -53635,159 +73912,48 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object + * Validates that the types of all values in this object match their expected types * recursively. * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * 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. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - known() + id() + groupingKey() + name() validated = true } @@ -53805,19 +73971,32 @@ 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 = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PriceType && value == other.value + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -53825,12 +74004,11 @@ private constructor( return true } - return other is BulkWithProration && + return other is GroupedWithMeteredMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && billingMode == other.billingMode && - bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && compositePriceFilters == other.compositePriceFilters && conversionRate == other.conversionRate && @@ -53841,6 +74019,8 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -53854,6 +74034,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -53863,7 +74044,6 @@ private constructor( billableMetric, billingCycleConfiguration, billingMode, - bulkWithProrationConfig, cadence, compositePriceFilters, conversionRate, @@ -53874,6 +74054,8 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + groupedWithMeteredMinimumConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -53887,6 +74069,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -53894,10 +74077,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class GroupedWithProratedMinimum + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -53914,7 +74097,8 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithProratedMinimumConfig: JsonField, + private val groupedWithMinMaxThresholdsConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -53928,6 +74112,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -53971,10 +74156,13 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - groupedWithProratedMinimumConfig: JsonField = + groupedWithMinMaxThresholdsConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -54005,6 +74193,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -54020,7 +74211,8 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithProratedMinimumConfig, + groupedWithMinMaxThresholdsConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -54034,6 +74226,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -54129,13 +74322,20 @@ private constructor( fixedPriceQuantity.getOptional("fixed_price_quantity") /** - * Configuration for grouped_with_prorated_minimum pricing + * Configuration for grouped_with_min_max_thresholds pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired("grouped_with_min_max_thresholds_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -54194,7 +74394,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_prorated_minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -54236,6 +74436,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -54367,15 +74576,25 @@ private constructor( fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** - * Returns the raw JSON value of [groupedWithProratedMinimumConfig]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [groupedWithProratedMinimumConfig], this method doesn't throw if the JSON field + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("grouped_with_prorated_minimum_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): JsonField = - groupedWithProratedMinimumConfig + fun _groupedWithMinMaxThresholdsConfig(): JsonField = + groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Returns the raw JSON value of [invoicingCycleConfiguration]. @@ -54491,6 +74710,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -54507,7 +74735,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithProratedMinimum]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```java @@ -54525,7 +74753,8 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithProratedMinimumConfig() + * .groupedWithMinMaxThresholdsConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -54542,7 +74771,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithProratedMinimum]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -54559,9 +74788,10 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = + private var groupedWithMinMaxThresholdsConfig: + JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -54569,50 +74799,54 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_prorated_minimum") + private var modelType: JsonValue = JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { - id = groupedWithProratedMinimum.id - billableMetric = groupedWithProratedMinimum.billableMetric - billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration - billingMode = groupedWithProratedMinimum.billingMode - cadence = groupedWithProratedMinimum.cadence + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { + id = groupedWithMinMaxThresholds.id + billableMetric = groupedWithMinMaxThresholds.billableMetric + billingCycleConfiguration = groupedWithMinMaxThresholds.billingCycleConfiguration + billingMode = groupedWithMinMaxThresholds.billingMode + cadence = groupedWithMinMaxThresholds.cadence compositePriceFilters = - groupedWithProratedMinimum.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedWithProratedMinimum.conversionRate - conversionRateConfig = groupedWithProratedMinimum.conversionRateConfig - createdAt = groupedWithProratedMinimum.createdAt - creditAllocation = groupedWithProratedMinimum.creditAllocation - currency = groupedWithProratedMinimum.currency - discount = groupedWithProratedMinimum.discount - externalPriceId = groupedWithProratedMinimum.externalPriceId - fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity - groupedWithProratedMinimumConfig = - groupedWithProratedMinimum.groupedWithProratedMinimumConfig - invoicingCycleConfiguration = groupedWithProratedMinimum.invoicingCycleConfiguration - item = groupedWithProratedMinimum.item - maximum = groupedWithProratedMinimum.maximum - maximumAmount = groupedWithProratedMinimum.maximumAmount - metadata = groupedWithProratedMinimum.metadata - minimum = groupedWithProratedMinimum.minimum - minimumAmount = groupedWithProratedMinimum.minimumAmount - modelType = groupedWithProratedMinimum.modelType - name = groupedWithProratedMinimum.name - planPhaseOrder = groupedWithProratedMinimum.planPhaseOrder - priceType = groupedWithProratedMinimum.priceType - replacesPriceId = groupedWithProratedMinimum.replacesPriceId + groupedWithMinMaxThresholds.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + createdAt = groupedWithMinMaxThresholds.createdAt + creditAllocation = groupedWithMinMaxThresholds.creditAllocation + currency = groupedWithMinMaxThresholds.currency + discount = groupedWithMinMaxThresholds.discount + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + item = groupedWithMinMaxThresholds.item + maximum = groupedWithMinMaxThresholds.maximum + maximumAmount = groupedWithMinMaxThresholds.maximumAmount + metadata = groupedWithMinMaxThresholds.metadata + minimum = groupedWithMinMaxThresholds.minimum + minimumAmount = groupedWithMinMaxThresholds.minimumAmount + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + planPhaseOrder = groupedWithMinMaxThresholds.planPhaseOrder + priceType = groupedWithMinMaxThresholds.priceType + replacesPriceId = groupedWithMinMaxThresholds.replacesPriceId dimensionalPriceConfiguration = - groupedWithProratedMinimum.dimensionalPriceConfiguration + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + licenseType = groupedWithMinMaxThresholds.licenseType additionalProperties = - groupedWithProratedMinimum.additionalProperties.toMutableMap() + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -54990,21 +75224,42 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - /** Configuration for grouped_with_prorated_minimum pricing */ - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = groupedWithMinMaxThresholdsConfig(JsonField.of(groupedWithMinMaxThresholdsConfig)) /** - * Sets [Builder.groupedWithProratedMinimumConfig] to an arbitrary JSON value. + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithProratedMinimumConfig] with a well-typed - * [GroupedWithProratedMinimumConfig] value instead. This method is primarily for + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a well-typed + * [GroupedWithMinMaxThresholdsConfig] value instead. This method is primarily for * setting the field to an undocumented or not yet supported value. */ - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: JsonField - ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: JsonField + ) = apply { this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } + + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? @@ -55142,7 +75397,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_with_prorated_minimum") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -55242,6 +75497,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -55262,7 +75540,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithProratedMinimum]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -55282,7 +75560,8 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithProratedMinimumConfig() + * .groupedWithMinMaxThresholdsConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -55298,8 +75577,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithProratedMinimum = - GroupedWithProratedMinimum( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -55317,9 +75596,10 @@ private constructor( checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, ), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -55333,13 +75613,23 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithProratedMinimum = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } @@ -55358,7 +75648,8 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedWithProratedMinimumConfig().validate() + groupedWithMinMaxThresholdsConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -55367,7 +75658,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_prorated_minimum")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -55376,6 +75667,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -55410,7 +75702,8 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -55419,13 +75712,14 @@ private constructor( (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -55518,6 +75812,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -55670,6 +75974,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -55919,6 +76233,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -56062,6 +76386,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -56194,6 +76528,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -56254,13 +76598,14 @@ private constructor( "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - /** Configuration for grouped_with_prorated_minimum pricing */ - class GroupedWithProratedMinimumConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, - private val minimum: JsonField, - private val unitRate: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -56269,16 +76614,19 @@ private constructor( @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("minimum") + @JsonProperty("maximum_charge") @ExcludeMissing - minimum: JsonField = JsonMissing.of(), - @JsonProperty("unit_rate") + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") @ExcludeMissing - unitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, minimum, unitRate, mutableMapOf()) + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * How to determine the groups that should each have a minimum + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -56287,22 +76635,31 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The minimum amount to charge per group + * The maximum amount to charge each group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun minimum(): String = minimum.getRequired("minimum") + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") /** - * The amount to charge per unit + * The minimum amount to charge each group, regardless of usage * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun unitRate(): String = unitRate.getRequired("unit_rate") + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") /** * Returns the raw JSON value of [groupingKey]. @@ -56315,19 +76672,34 @@ private constructor( fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [minimum]. + * Returns the raw JSON value of [maximumCharge]. * - * Unlike [minimum], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge /** - * Returns the raw JSON value of [unitRate]. + * Returns the raw JSON value of [minimumCharge]. * - * Unlike [unitRate], this method doesn't throw if the JSON field has an unexpected + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("unit_rate") @ExcludeMissing fun _unitRate(): JsonField = unitRate + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -56345,38 +76717,41 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithProratedMinimumConfig]. + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```java * .groupingKey() - * .minimum() - * .unitRate() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithProratedMinimumConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { private var groupingKey: JsonField? = null - private var minimum: JsonField? = null - private var unitRate: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { - groupingKey = groupedWithProratedMinimumConfig.groupingKey - minimum = groupedWithProratedMinimumConfig.minimum - unitRate = groupedWithProratedMinimumConfig.unitRate + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() + groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() } - /** How to determine the groups that should each have a minimum */ + /** The event property used to group before applying thresholds */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** @@ -56390,29 +76765,49 @@ private constructor( this.groupingKey = groupingKey } - /** The minimum amount to charge per group */ - fun minimum(minimum: String) = minimum(JsonField.of(minimum)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) /** - * Sets [Builder.minimum] to an arbitrary JSON value. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * You should usually call [Builder.minimum] with a well-typed [String] value + * You should usually call [Builder.maximumCharge] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } - /** The amount to charge per unit */ - fun unitRate(unitRate: String) = unitRate(JsonField.of(unitRate)) + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) /** - * Sets [Builder.unitRate] to an arbitrary JSON value. + * Sets [Builder.minimumCharge] to an arbitrary JSON value. * - * You should usually call [Builder.unitRate] with a well-typed [String] value + * You should usually call [Builder.minimumCharge] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun unitRate(unitRate: JsonField) = apply { this.unitRate = unitRate } + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -56437,38 +76832,51 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithProratedMinimumConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .groupingKey() - * .minimum() - * .unitRate() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig( + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( checkRequired("groupingKey", groupingKey), - checkRequired("minimum", minimum), - checkRequired("unitRate", unitRate), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithProratedMinimumConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } groupingKey() - minimum() - unitRate() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -56489,29 +76897,37 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (minimum.asKnown().isPresent) 1 else 0) + - (if (unitRate.asKnown().isPresent) 1 else 0) + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithProratedMinimumConfig && + return other is GroupedWithMinMaxThresholdsConfig && groupingKey == other.groupingKey && - minimum == other.minimum && - unitRate == other.unitRate && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(groupingKey, minimum, unitRate, additionalProperties) + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimumConfig{groupingKey=$groupingKey, minimum=$minimum, unitRate=$unitRate, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -56571,159 +76987,434 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object + * Validates that the types of all values in this object match their expected types * recursively. * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - known() + id() + groupingKey() + name() validated = true } @@ -56741,19 +77432,32 @@ 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 = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PriceType && value == other.value + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -56761,7 +77465,7 @@ private constructor( return true } - return other is GroupedWithProratedMinimum && + return other is GroupedWithMinMaxThresholds && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -56776,7 +77480,8 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && + groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -56790,6 +77495,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -56809,7 +77515,8 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithProratedMinimumConfig, + groupedWithMinMaxThresholdsConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -56823,6 +77530,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -56830,10 +77538,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class GroupedWithMeteredMinimum + class MatrixWithDisplayName @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -56850,9 +77558,10 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithMeteredMinimumConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, + private val matrixWithDisplayNameConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -56864,6 +77573,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -56907,14 +77617,16 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_metered_minimum_config") + @JsonProperty("invoice_grouping_key") @ExcludeMissing - groupedWithMeteredMinimumConfig: JsonField = - JsonMissing.of(), + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + matrixWithDisplayNameConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -56941,6 +77653,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -56956,9 +77671,10 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMeteredMinimumConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, + matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -56970,6 +77686,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -57065,13 +77782,11 @@ private constructor( fixedPriceQuantity.getOptional("fixed_price_quantity") /** - * Configuration for grouped_with_metered_minimum pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -57089,6 +77804,15 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") + /** + * Configuration for matrix_with_display_name pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -57130,7 +77854,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_metered_minimum") + * JsonValue.from("matrix_with_display_name") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -57172,6 +77896,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -57303,15 +78036,14 @@ private constructor( fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** - * Returns the raw JSON value of [groupedWithMeteredMinimumConfig]. + * Returns the raw JSON value of [invoiceGroupingKey]. * - * Unlike [groupedWithMeteredMinimumConfig], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("grouped_with_metered_minimum_config") + @JsonProperty("invoice_grouping_key") @ExcludeMissing - fun _groupedWithMeteredMinimumConfig(): JsonField = - groupedWithMeteredMinimumConfig + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Returns the raw JSON value of [invoicingCycleConfiguration]. @@ -57331,6 +78063,17 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + /** + * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * + * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + /** * Returns the raw JSON value of [maximum]. * @@ -57427,6 +78170,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -57442,8 +78194,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMeteredMinimum]. + * Returns a mutable builder for constructing an instance of [MatrixWithDisplayName]. * * The following fields are required: * ```java @@ -57461,9 +78212,10 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMeteredMinimumConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() + * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -57478,7 +78230,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimum]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -57495,59 +78247,59 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithMeteredMinimumConfig: - JsonField? = - null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null + private var matrixWithDisplayNameConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_metered_minimum") + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { - id = groupedWithMeteredMinimum.id - billableMetric = groupedWithMeteredMinimum.billableMetric - billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration - billingMode = groupedWithMeteredMinimum.billingMode - cadence = groupedWithMeteredMinimum.cadence + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + id = matrixWithDisplayName.id + billableMetric = matrixWithDisplayName.billableMetric + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + billingMode = matrixWithDisplayName.billingMode + cadence = matrixWithDisplayName.cadence compositePriceFilters = - groupedWithMeteredMinimum.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedWithMeteredMinimum.conversionRate - conversionRateConfig = groupedWithMeteredMinimum.conversionRateConfig - createdAt = groupedWithMeteredMinimum.createdAt - creditAllocation = groupedWithMeteredMinimum.creditAllocation - currency = groupedWithMeteredMinimum.currency - discount = groupedWithMeteredMinimum.discount - externalPriceId = groupedWithMeteredMinimum.externalPriceId - fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity - groupedWithMeteredMinimumConfig = - groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig - invoicingCycleConfiguration = groupedWithMeteredMinimum.invoicingCycleConfiguration - item = groupedWithMeteredMinimum.item - maximum = groupedWithMeteredMinimum.maximum - maximumAmount = groupedWithMeteredMinimum.maximumAmount - metadata = groupedWithMeteredMinimum.metadata - minimum = groupedWithMeteredMinimum.minimum - minimumAmount = groupedWithMeteredMinimum.minimumAmount - modelType = groupedWithMeteredMinimum.modelType - name = groupedWithMeteredMinimum.name - planPhaseOrder = groupedWithMeteredMinimum.planPhaseOrder - priceType = groupedWithMeteredMinimum.priceType - replacesPriceId = groupedWithMeteredMinimum.replacesPriceId - dimensionalPriceConfiguration = - groupedWithMeteredMinimum.dimensionalPriceConfiguration - additionalProperties = groupedWithMeteredMinimum.additionalProperties.toMutableMap() + matrixWithDisplayName.compositePriceFilters.map { it.toMutableList() } + conversionRate = matrixWithDisplayName.conversionRate + conversionRateConfig = matrixWithDisplayName.conversionRateConfig + createdAt = matrixWithDisplayName.createdAt + creditAllocation = matrixWithDisplayName.creditAllocation + currency = matrixWithDisplayName.currency + discount = matrixWithDisplayName.discount + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = matrixWithDisplayName.invoicingCycleConfiguration + item = matrixWithDisplayName.item + matrixWithDisplayNameConfig = matrixWithDisplayName.matrixWithDisplayNameConfig + maximum = matrixWithDisplayName.maximum + maximumAmount = matrixWithDisplayName.maximumAmount + metadata = matrixWithDisplayName.metadata + minimum = matrixWithDisplayName.minimum + minimumAmount = matrixWithDisplayName.minimumAmount + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + planPhaseOrder = matrixWithDisplayName.planPhaseOrder + priceType = matrixWithDisplayName.priceType + replacesPriceId = matrixWithDisplayName.replacesPriceId + dimensionalPriceConfiguration = matrixWithDisplayName.dimensionalPriceConfiguration + licenseType = matrixWithDisplayName.licenseType + additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -57925,21 +78677,26 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - /** Configuration for grouped_with_metered_minimum pricing */ - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) /** - * Sets [Builder.groupedWithMeteredMinimumConfig] to an arbitrary JSON value. + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMeteredMinimumConfig] with a well-typed - * [GroupedWithMeteredMinimumConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: JsonField - ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? @@ -57979,6 +78736,22 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } + /** Configuration for matrix_with_display_name pricing */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + /** + * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithDisplayNameConfig] with a well-typed + * [MatrixWithDisplayNameConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -58077,7 +78850,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_with_metered_minimum") + * JsonValue.from("matrix_with_display_name") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -58177,6 +78950,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -58197,7 +78993,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMeteredMinimum]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -58217,9 +79013,10 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMeteredMinimumConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() + * .matrixWithDisplayNameConfig() * .maximum() * .maximumAmount() * .metadata() @@ -58233,8 +79030,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMeteredMinimum = - GroupedWithMeteredMinimum( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -58251,12 +79048,10 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithMeteredMinimumConfig", - groupedWithMeteredMinimumConfig, - ), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -58268,13 +79063,23 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMeteredMinimum = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -58293,16 +79098,17 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedWithMeteredMinimumConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() + matrixWithDisplayNameConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_metered_minimum")) { + if (it != JsonValue.from("matrix_with_display_name")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -58311,6 +79117,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -58345,22 +79152,22 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -58453,6 +79260,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -58605,6 +79422,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -58854,6 +79681,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -58997,6 +79834,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -59129,6 +79976,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -59189,66 +80046,24 @@ private constructor( "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - /** Configuration for grouped_with_metered_minimum pricing */ - class GroupedWithMeteredMinimumConfig + /** Configuration for matrix_with_display_name pricing */ + class MatrixWithDisplayNameConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val minimumUnitAmount: JsonField, - private val pricingKey: JsonField, - private val scalingFactors: JsonField>, - private val scalingKey: JsonField, + private val dimension: JsonField, private val unitAmounts: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("minimum_unit_amount") - @ExcludeMissing - minimumUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("pricing_key") - @ExcludeMissing - pricingKey: JsonField = JsonMissing.of(), - @JsonProperty("scaling_factors") - @ExcludeMissing - scalingFactors: JsonField> = JsonMissing.of(), - @JsonProperty("scaling_key") + @JsonProperty("dimension") @ExcludeMissing - scalingKey: JsonField = JsonMissing.of(), + dimension: JsonField = JsonMissing.of(), @JsonProperty("unit_amounts") @ExcludeMissing unitAmounts: JsonField> = JsonMissing.of(), - ) : this( - groupingKey, - minimumUnitAmount, - pricingKey, - scalingFactors, - scalingKey, - unitAmounts, - mutableMapOf(), - ) - - /** - * Used to partition the usage into groups. The minimum amount is applied to each group. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") - - /** - * The minimum amount to charge per group per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumUnitAmount(): String = minimumUnitAmount.getRequired("minimum_unit_amount") + ) : this(dimension, unitAmounts, mutableMapOf()) /** * Used to determine the unit rate @@ -59257,30 +80072,10 @@ private constructor( * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun pricingKey(): String = pricingKey.getRequired("pricing_key") - - /** - * Scale the unit rates by the scaling factor. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun scalingFactors(): List = - scalingFactors.getRequired("scaling_factors") - - /** - * Used to determine the unit rate scaling factor - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun scalingKey(): String = scalingKey.getRequired("scaling_key") + fun dimension(): String = dimension.getRequired("dimension") /** - * Apply per unit pricing to each pricing value. The minimum amount is applied any - * unmatched usage. + * Apply per unit pricing to each dimension value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -59289,54 +80084,14 @@ private constructor( fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey - - /** - * Returns the raw JSON value of [minimumUnitAmount]. - * - * Unlike [minimumUnitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_unit_amount") - @ExcludeMissing - fun _minimumUnitAmount(): JsonField = minimumUnitAmount - - /** - * Returns the raw JSON value of [pricingKey]. - * - * Unlike [pricingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("pricing_key") - @ExcludeMissing - fun _pricingKey(): JsonField = pricingKey - - /** - * Returns the raw JSON value of [scalingFactors]. - * - * Unlike [scalingFactors], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("scaling_factors") - @ExcludeMissing - fun _scalingFactors(): JsonField> = scalingFactors - - /** - * Returns the raw JSON value of [scalingKey]. + * Returns the raw JSON value of [dimension]. * - * Unlike [scalingKey], this method doesn't throw if the JSON field has an unexpected + * Unlike [dimension], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("scaling_key") + @JsonProperty("dimension") @ExcludeMissing - fun _scalingKey(): JsonField = scalingKey + fun _dimension(): JsonField = dimension /** * Returns the raw JSON value of [unitAmounts]. @@ -59364,139 +80119,47 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMeteredMinimumConfig]. + * [MatrixWithDisplayNameConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .minimumUnitAmount() - * .pricingKey() - * .scalingFactors() - * .scalingKey() + * .dimension() * .unitAmounts() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimumConfig]. */ + /** A builder for [MatrixWithDisplayNameConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var minimumUnitAmount: JsonField? = null - private var pricingKey: JsonField? = null - private var scalingFactors: JsonField>? = null - private var scalingKey: JsonField? = null + private var dimension: JsonField? = null private var unitAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = apply { - groupingKey = groupedWithMeteredMinimumConfig.groupingKey - minimumUnitAmount = groupedWithMeteredMinimumConfig.minimumUnitAmount - pricingKey = groupedWithMeteredMinimumConfig.pricingKey - scalingFactors = - groupedWithMeteredMinimumConfig.scalingFactors.map { it.toMutableList() } - scalingKey = groupedWithMeteredMinimumConfig.scalingKey - unitAmounts = - groupedWithMeteredMinimumConfig.unitAmounts.map { it.toMutableList() } - additionalProperties = - groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() - } - - /** - * Used to partition the usage into groups. The minimum amount is applied to each - * group. - */ - fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The minimum amount to charge per group per unit */ - fun minimumUnitAmount(minimumUnitAmount: String) = - minimumUnitAmount(JsonField.of(minimumUnitAmount)) - - /** - * Sets [Builder.minimumUnitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumUnitAmount] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun minimumUnitAmount(minimumUnitAmount: JsonField) = apply { - this.minimumUnitAmount = minimumUnitAmount - } + internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = + apply { + dimension = matrixWithDisplayNameConfig.dimension + unitAmounts = + matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + additionalProperties = + matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + } /** Used to determine the unit rate */ - fun pricingKey(pricingKey: String) = pricingKey(JsonField.of(pricingKey)) - - /** - * Sets [Builder.pricingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.pricingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun pricingKey(pricingKey: JsonField) = apply { - this.pricingKey = pricingKey - } - - /** Scale the unit rates by the scaling factor. */ - fun scalingFactors(scalingFactors: List) = - scalingFactors(JsonField.of(scalingFactors)) - - /** - * Sets [Builder.scalingFactors] to an arbitrary JSON value. - * - * You should usually call [Builder.scalingFactors] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun scalingFactors(scalingFactors: JsonField>) = apply { - this.scalingFactors = scalingFactors.map { it.toMutableList() } - } - - /** - * Adds a single [ScalingFactor] to [scalingFactors]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addScalingFactor(scalingFactor: ScalingFactor) = apply { - scalingFactors = - (scalingFactors ?: JsonField.of(mutableListOf())).also { - checkKnown("scalingFactors", it).add(scalingFactor) - } - } - - /** Used to determine the unit rate scaling factor */ - fun scalingKey(scalingKey: String) = scalingKey(JsonField.of(scalingKey)) + fun dimension(dimension: String) = dimension(JsonField.of(dimension)) /** - * Sets [Builder.scalingKey] to an arbitrary JSON value. + * Sets [Builder.dimension] to an arbitrary JSON value. * - * You should usually call [Builder.scalingKey] with a well-typed [String] value + * You should usually call [Builder.dimension] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun scalingKey(scalingKey: JsonField) = apply { - this.scalingKey = scalingKey - } + fun dimension(dimension: JsonField) = apply { this.dimension = dimension } - /** - * Apply per unit pricing to each pricing value. The minimum amount is applied any - * unmatched usage. - */ + /** Apply per unit pricing to each dimension value */ fun unitAmounts(unitAmounts: List) = unitAmounts(JsonField.of(unitAmounts)) @@ -59546,314 +80209,107 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMeteredMinimumConfig]. + * Returns an immutable instance of [MatrixWithDisplayNameConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .groupingKey() - * .minimumUnitAmount() - * .pricingKey() - * .scalingFactors() - * .scalingKey() + * .dimension() * .unitAmounts() * ``` * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("minimumUnitAmount", minimumUnitAmount), - checkRequired("pricingKey", pricingKey), - checkRequired("scalingFactors", scalingFactors).map { it.toImmutable() }, - checkRequired("scalingKey", scalingKey), - checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GroupedWithMeteredMinimumConfig = apply { - if (validated) { - return@apply - } - - groupingKey() - minimumUnitAmount() - pricingKey() - scalingFactors().forEach { it.validate() } - scalingKey() - unitAmounts().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (minimumUnitAmount.asKnown().isPresent) 1 else 0) + - (if (pricingKey.asKnown().isPresent) 1 else 0) + - (scalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (scalingKey.asKnown().isPresent) 1 else 0) + - (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a scaling factor */ - class ScalingFactor - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val scalingFactor: JsonField, - private val scalingValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("scaling_factor") - @ExcludeMissing - scalingFactor: JsonField = JsonMissing.of(), - @JsonProperty("scaling_value") - @ExcludeMissing - scalingValue: JsonField = JsonMissing.of(), - ) : this(scalingFactor, scalingValue, mutableMapOf()) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun scalingValue(): String = scalingValue.getRequired("scaling_value") - - /** - * Returns the raw JSON value of [scalingFactor]. - * - * Unlike [scalingFactor], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("scaling_factor") - @ExcludeMissing - fun _scalingFactor(): JsonField = scalingFactor - - /** - * Returns the raw JSON value of [scalingValue]. - * - * Unlike [scalingValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("scaling_value") - @ExcludeMissing - fun _scalingValue(): JsonField = scalingValue - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ScalingFactor]. - * - * The following fields are required: - * ```java - * .scalingFactor() - * .scalingValue() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalingFactor]. */ - class Builder internal constructor() { - - private var scalingFactor: JsonField? = null - private var scalingValue: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scalingFactor: ScalingFactor) = apply { - this.scalingFactor = scalingFactor.scalingFactor - scalingValue = scalingFactor.scalingValue - additionalProperties = scalingFactor.additionalProperties.toMutableMap() - } - - fun scalingFactor(scalingFactor: String) = - scalingFactor(JsonField.of(scalingFactor)) - - /** - * Sets [Builder.scalingFactor] to an arbitrary JSON value. - * - * You should usually call [Builder.scalingFactor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun scalingFactor(scalingFactor: JsonField) = apply { - this.scalingFactor = scalingFactor - } - - fun scalingValue(scalingValue: String) = - scalingValue(JsonField.of(scalingValue)) - - /** - * Sets [Builder.scalingValue] to an arbitrary JSON value. - * - * You should usually call [Builder.scalingValue] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun scalingValue(scalingValue: JsonField) = apply { - this.scalingValue = scalingValue - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ScalingFactor]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .scalingFactor() - * .scalingValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ScalingFactor = - ScalingFactor( - checkRequired("scalingFactor", scalingFactor), - checkRequired("scalingValue", scalingValue), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ScalingFactor = apply { - if (validated) { - return@apply - } - - scalingFactor() - scalingValue() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (scalingFactor.asKnown().isPresent) 1 else 0) + - (if (scalingValue.asKnown().isPresent) 1 else 0) + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithDisplayNameConfig = + MatrixWithDisplayNameConfig( + checkRequired("dimension", dimension), + checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is ScalingFactor && - scalingFactor == other.scalingFactor && - scalingValue == other.scalingValue && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MatrixWithDisplayNameConfig = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(scalingFactor, scalingValue, additionalProperties) - } + dimension() + unitAmounts().forEach { it.validate() } + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString() = - "ScalingFactor{scalingFactor=$scalingFactor, scalingValue=$scalingValue, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dimension.asKnown().isPresent) 1 else 0) + + (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a unit amount */ + /** Configuration for a unit amount item */ class UnitAmount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val pricingValue: JsonField, + private val dimensionValue: JsonField, + private val displayName: JsonField, private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("pricing_value") + @JsonProperty("dimension_value") @ExcludeMissing - pricingValue: JsonField = JsonMissing.of(), + dimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), - ) : this(pricingValue, unitAmount, mutableMapOf()) + ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) /** + * The dimension value + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun pricingValue(): String = pricingValue.getRequired("pricing_value") + fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + + /** + * Display name for this dimension value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun displayName(): String = displayName.getRequired("display_name") /** * Per unit amount @@ -59865,14 +80321,24 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [pricingValue]. + * Returns the raw JSON value of [dimensionValue]. * - * Unlike [pricingValue], this method doesn't throw if the JSON field has an + * Unlike [dimensionValue], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("pricing_value") + @JsonProperty("dimension_value") @ExcludeMissing - fun _pricingValue(): JsonField = pricingValue + fun _dimensionValue(): JsonField = dimensionValue + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName /** * Returns the raw JSON value of [unitAmount]. @@ -59903,7 +80369,8 @@ private constructor( * * The following fields are required: * ```java - * .pricingValue() + * .dimensionValue() + * .displayName() * .unitAmount() * ``` */ @@ -59913,29 +80380,46 @@ private constructor( /** A builder for [UnitAmount]. */ class Builder internal constructor() { - private var pricingValue: JsonField? = null + private var dimensionValue: JsonField? = null + private var displayName: JsonField? = null private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(unitAmount: UnitAmount) = apply { - pricingValue = unitAmount.pricingValue + dimensionValue = unitAmount.dimensionValue + displayName = unitAmount.displayName this.unitAmount = unitAmount.unitAmount additionalProperties = unitAmount.additionalProperties.toMutableMap() } - fun pricingValue(pricingValue: String) = - pricingValue(JsonField.of(pricingValue)) + /** The dimension value */ + fun dimensionValue(dimensionValue: String) = + dimensionValue(JsonField.of(dimensionValue)) /** - * Sets [Builder.pricingValue] to an arbitrary JSON value. + * Sets [Builder.dimensionValue] to an arbitrary JSON value. * - * You should usually call [Builder.pricingValue] with a well-typed [String] + * You should usually call [Builder.dimensionValue] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun pricingValue(pricingValue: JsonField) = apply { - this.pricingValue = pricingValue + fun dimensionValue(dimensionValue: JsonField) = apply { + this.dimensionValue = dimensionValue + } + + /** Display name for this dimension value */ + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun displayName(displayName: JsonField) = apply { + this.displayName = displayName } /** Per unit amount */ @@ -59981,7 +80465,8 @@ private constructor( * * The following fields are required: * ```java - * .pricingValue() + * .dimensionValue() + * .displayName() * .unitAmount() * ``` * @@ -59989,7 +80474,8 @@ private constructor( */ fun build(): UnitAmount = UnitAmount( - checkRequired("pricingValue", pricingValue), + checkRequired("dimensionValue", dimensionValue), + checkRequired("displayName", displayName), checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) @@ -59997,12 +80483,23 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): UnitAmount = apply { if (validated) { return@apply } - pricingValue() + dimensionValue() + displayName() unitAmount() validated = true } @@ -60023,7 +80520,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (pricingValue.asKnown().isPresent) 1 else 0) + + (if (dimensionValue.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -60032,19 +80530,20 @@ private constructor( } return other is UnitAmount && - pricingValue == other.pricingValue && + dimensionValue == other.dimensionValue && + displayName == other.displayName && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(pricingValue, unitAmount, additionalProperties) + Objects.hash(dimensionValue, displayName, unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UnitAmount{pricingValue=$pricingValue, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -60052,32 +80551,20 @@ private constructor( return true } - return other is GroupedWithMeteredMinimumConfig && - groupingKey == other.groupingKey && - minimumUnitAmount == other.minimumUnitAmount && - pricingKey == other.pricingKey && - scalingFactors == other.scalingFactors && - scalingKey == other.scalingKey && + return other is MatrixWithDisplayNameConfig && + dimension == other.dimension && unitAmounts == other.unitAmounts && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - minimumUnitAmount, - pricingKey, - scalingFactors, - scalingKey, - unitAmounts, - additionalProperties, - ) + Objects.hash(dimension, unitAmounts, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimumConfig{groupingKey=$groupingKey, minimumUnitAmount=$minimumUnitAmount, pricingKey=$pricingKey, scalingFactors=$scalingFactors, scalingKey=$scalingKey, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" } /** @@ -60137,159 +80624,434 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object + * Validates that the types of all values in this object match their expected types * recursively. * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * 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. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - known() + id() + groupingKey() + name() validated = true } @@ -60307,19 +81069,32 @@ 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 = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PriceType && value == other.value + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -60327,7 +81102,7 @@ private constructor( return true } - return other is GroupedWithMeteredMinimum && + return other is MatrixWithDisplayName && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -60342,9 +81117,10 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && + matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -60356,6 +81132,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -60375,9 +81152,10 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMeteredMinimumConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, + matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, @@ -60389,6 +81167,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -60396,10 +81175,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class GroupedTieredPackage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -60416,7 +81195,8 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedWithMinMaxThresholdsConfig: JsonField, + private val groupedTieredPackageConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -60430,6 +81210,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -60473,10 +81254,12 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("grouped_tiered_package_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: JsonField = - JsonMissing.of(), + groupedTieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -60507,6 +81290,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -60522,7 +81308,8 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMinMaxThresholdsConfig, + groupedTieredPackageConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -60536,6 +81323,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -60631,13 +81419,20 @@ private constructor( fixedPriceQuantity.getOptional("fixed_price_quantity") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for grouped_tiered_package pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired("grouped_with_min_max_thresholds_config") + fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -60696,7 +81491,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("grouped_tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -60738,6 +81533,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -60869,15 +81673,25 @@ private constructor( fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [groupedTieredPackageConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("grouped_tiered_package_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): JsonField = - groupedWithMinMaxThresholdsConfig + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Returns the raw JSON value of [invoicingCycleConfiguration]. @@ -60993,6 +81807,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -61008,8 +81831,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. * * The following fields are required: * ```java @@ -61027,7 +81849,8 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMinMaxThresholdsConfig() + * .groupedTieredPackageConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -61044,7 +81867,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -61061,9 +81884,8 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null + private var groupedTieredPackageConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -61071,51 +81893,50 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { - id = groupedWithMinMaxThresholds.id - billableMetric = groupedWithMinMaxThresholds.billableMetric - billingCycleConfiguration = groupedWithMinMaxThresholds.billingCycleConfiguration - billingMode = groupedWithMinMaxThresholds.billingMode - cadence = groupedWithMinMaxThresholds.cadence + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + id = groupedTieredPackage.id + billableMetric = groupedTieredPackage.billableMetric + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + billingMode = groupedTieredPackage.billingMode + cadence = groupedTieredPackage.cadence compositePriceFilters = - groupedWithMinMaxThresholds.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - createdAt = groupedWithMinMaxThresholds.createdAt - creditAllocation = groupedWithMinMaxThresholds.creditAllocation - currency = groupedWithMinMaxThresholds.currency - discount = groupedWithMinMaxThresholds.discount - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - item = groupedWithMinMaxThresholds.item - maximum = groupedWithMinMaxThresholds.maximum - maximumAmount = groupedWithMinMaxThresholds.maximumAmount - metadata = groupedWithMinMaxThresholds.metadata - minimum = groupedWithMinMaxThresholds.minimum - minimumAmount = groupedWithMinMaxThresholds.minimumAmount - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - planPhaseOrder = groupedWithMinMaxThresholds.planPhaseOrder - priceType = groupedWithMinMaxThresholds.priceType - replacesPriceId = groupedWithMinMaxThresholds.replacesPriceId - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + groupedTieredPackage.compositePriceFilters.map { it.toMutableList() } + conversionRate = groupedTieredPackage.conversionRate + conversionRateConfig = groupedTieredPackage.conversionRateConfig + createdAt = groupedTieredPackage.createdAt + creditAllocation = groupedTieredPackage.creditAllocation + currency = groupedTieredPackage.currency + discount = groupedTieredPackage.discount + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = groupedTieredPackage.invoicingCycleConfiguration + item = groupedTieredPackage.item + maximum = groupedTieredPackage.maximum + maximumAmount = groupedTieredPackage.maximumAmount + metadata = groupedTieredPackage.metadata + minimum = groupedTieredPackage.minimum + minimumAmount = groupedTieredPackage.minimumAmount + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + planPhaseOrder = groupedTieredPackage.planPhaseOrder + priceType = groupedTieredPackage.priceType + replacesPriceId = groupedTieredPackage.replacesPriceId + dimensionalPriceConfiguration = groupedTieredPackage.dimensionalPriceConfiguration + licenseType = groupedTieredPackage.licenseType + additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -61493,21 +82314,41 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = groupedWithMinMaxThresholdsConfig(JsonField.of(groupedWithMinMaxThresholdsConfig)) + /** Configuration for grouped_tiered_package pricing */ + fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = + groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a well-typed - * [GroupedWithMinMaxThresholdsConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.groupedTieredPackageConfig] with a well-typed + * [GroupedTieredPackageConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: JsonField - ) = apply { this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? @@ -61645,7 +82486,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("grouped_tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -61745,6 +82586,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -61765,7 +82629,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -61785,7 +82649,8 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedWithMinMaxThresholdsConfig() + * .groupedTieredPackageConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -61801,8 +82666,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -61819,10 +82684,8 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -61836,13 +82699,23 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -61861,7 +82734,8 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedWithMinMaxThresholdsConfig().validate() + groupedTieredPackageConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -61870,7 +82744,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("grouped_tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -61879,6 +82753,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -61913,7 +82788,8 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -61921,14 +82797,13 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -62021,6 +82896,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -62173,6 +83058,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -62422,6 +83317,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -62565,6 +83470,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -62697,6 +83612,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -62757,14 +83682,13 @@ private constructor( "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for grouped_tiered_package pricing */ + class GroupedTieredPackageConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @@ -62773,19 +83697,16 @@ private constructor( @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + @JsonProperty("package_size") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) /** - * The event property used to group before applying thresholds + * The event property used to group before tiering * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -62794,31 +83715,21 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The maximum amount to charge each group - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - - /** - * The minimum amount to charge each group, regardless of usage - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun packageSize(): String = packageSize.getRequired("package_size") /** - * The base price charged per group + * Apply tiered pricing after rounding up the quantity to the package size. Tiers are + * defined using exclusive lower bounds. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun tiers(): List = tiers.getRequired("tiers") /** * Returns the raw JSON value of [groupingKey]. @@ -62831,34 +83742,21 @@ private constructor( fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [packageSize]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an unexpected + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("minimum_charge") + @JsonProperty("package_size") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _packageSize(): JsonField = packageSize /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [tiers]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("per_unit_rate") - @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -62876,41 +83774,36 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [GroupedTieredPackageConfig]. * * The following fields are required: * ```java * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .packageSize() + * .tiers() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [GroupedTieredPackageConfig]. */ class Builder internal constructor() { private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { + groupingKey = groupedTieredPackageConfig.groupingKey + packageSize = groupedTieredPackageConfig.packageSize + tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() + groupedTieredPackageConfig.additionalProperties.toMutableMap() } - /** The event property used to group before applying thresholds */ + /** The event property used to group before tiering */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** @@ -62924,48 +83817,46 @@ private constructor( this.groupingKey = groupingKey } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.packageSize] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed [String] value + * You should usually call [Builder.packageSize] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** + * Apply tiered pricing after rounding up the quantity to the package size. Tiers + * are defined using exclusive lower bounds. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.tiers] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed [String] value + * You should usually call [Builder.tiers] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = perUnitRate(JsonField.of(perUnitRate)) - /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Adds a single [Tier] to [tiers]. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -62991,41 +83882,48 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [GroupedTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .packageSize() + * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( + fun build(): GroupedTieredPackageConfig = + GroupedTieredPackageConfig( checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedTieredPackageConfig = apply { if (validated) { return@apply } groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -63046,37 +83944,255 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val perUnit: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("per_unit") + @ExcludeMissing + perUnit: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(perUnit, tierLowerBound, mutableMapOf()) + + /** + * Per package + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnit(): String = perUnit.getRequired("per_unit") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + + /** + * Returns the raw JSON value of [perUnit]. + * + * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("per_unit") + @ExcludeMissing + fun _perUnit(): JsonField = perUnit + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var perUnit: JsonField? = null + private var tierLowerBound: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + perUnit = tier.perUnit + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per package */ + fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + + /** + * Sets [Builder.perUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnit] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .perUnit() + * .tierLowerBound() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("perUnit", perUnit), + checkRequired("tierLowerBound", tierLowerBound), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + perUnit() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (perUnit.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + perUnit == other.perUnit && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(perUnit, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && + return other is GroupedTieredPackageConfig && groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -63145,6 +84261,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -63283,6 +84409,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -63321,12 +84457,280 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholds && + return other is GroupedTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -63341,7 +84745,8 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && + groupedTieredPackageConfig == other.groupedTieredPackageConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -63355,6 +84760,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -63374,7 +84780,8 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedWithMinMaxThresholdsConfig, + groupedTieredPackageConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -63388,6 +84795,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -63395,10 +84803,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class MatrixWithDisplayName + class MaxGroupTieredPackage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -63415,9 +84823,10 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, - private val matrixWithDisplayNameConfig: JsonField, + private val maxGroupTieredPackageConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -63429,6 +84838,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -63472,13 +84882,16 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_display_name_config") + @JsonProperty("max_group_tiered_package_config") @ExcludeMissing - matrixWithDisplayNameConfig: JsonField = JsonMissing.of(), + maxGroupTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -63505,6 +84918,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -63520,9 +84936,10 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, - matrixWithDisplayNameConfig, + maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -63534,6 +84951,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -63628,6 +85046,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -63645,13 +85070,13 @@ private constructor( fun item(): ItemSlim = item.getRequired("item") /** - * Configuration for matrix_with_display_name pricing + * Configuration for max_group_tiered_package pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = - matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -63694,7 +85119,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("matrix_with_display_name") + * JsonValue.from("max_group_tiered_package") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -63736,6 +85161,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -63866,6 +85300,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -63885,15 +85329,15 @@ private constructor( @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item /** - * Returns the raw JSON value of [matrixWithDisplayNameConfig]. + * Returns the raw JSON value of [maxGroupTieredPackageConfig]. * - * Unlike [matrixWithDisplayNameConfig], this method doesn't throw if the JSON field has an + * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("matrix_with_display_name_config") + @JsonProperty("max_group_tiered_package_config") @ExcludeMissing - fun _matrixWithDisplayNameConfig(): JsonField = - matrixWithDisplayNameConfig + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig /** * Returns the raw JSON value of [maximum]. @@ -63991,6 +85435,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -64006,7 +85459,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MatrixWithDisplayName]. + * Returns a mutable builder for constructing an instance of [MaxGroupTieredPackage]. * * The following fields are required: * ```java @@ -64024,9 +85477,10 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() - * .matrixWithDisplayNameConfig() + * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -64041,7 +85495,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixWithDisplayName]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -64058,55 +85512,59 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null - private var matrixWithDisplayNameConfig: JsonField? = null + private var maxGroupTieredPackageConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { - id = matrixWithDisplayName.id - billableMetric = matrixWithDisplayName.billableMetric - billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration - billingMode = matrixWithDisplayName.billingMode - cadence = matrixWithDisplayName.cadence + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + id = maxGroupTieredPackage.id + billableMetric = maxGroupTieredPackage.billableMetric + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + billingMode = maxGroupTieredPackage.billingMode + cadence = maxGroupTieredPackage.cadence compositePriceFilters = - matrixWithDisplayName.compositePriceFilters.map { it.toMutableList() } - conversionRate = matrixWithDisplayName.conversionRate - conversionRateConfig = matrixWithDisplayName.conversionRateConfig - createdAt = matrixWithDisplayName.createdAt - creditAllocation = matrixWithDisplayName.creditAllocation - currency = matrixWithDisplayName.currency - discount = matrixWithDisplayName.discount - externalPriceId = matrixWithDisplayName.externalPriceId - fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity - invoicingCycleConfiguration = matrixWithDisplayName.invoicingCycleConfiguration - item = matrixWithDisplayName.item - matrixWithDisplayNameConfig = matrixWithDisplayName.matrixWithDisplayNameConfig - maximum = matrixWithDisplayName.maximum - maximumAmount = matrixWithDisplayName.maximumAmount - metadata = matrixWithDisplayName.metadata - minimum = matrixWithDisplayName.minimum - minimumAmount = matrixWithDisplayName.minimumAmount - modelType = matrixWithDisplayName.modelType - name = matrixWithDisplayName.name - planPhaseOrder = matrixWithDisplayName.planPhaseOrder - priceType = matrixWithDisplayName.priceType - replacesPriceId = matrixWithDisplayName.replacesPriceId - dimensionalPriceConfiguration = matrixWithDisplayName.dimensionalPriceConfiguration - additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() + maxGroupTieredPackage.compositePriceFilters.map { it.toMutableList() } + conversionRate = maxGroupTieredPackage.conversionRate + conversionRateConfig = maxGroupTieredPackage.conversionRateConfig + createdAt = maxGroupTieredPackage.createdAt + creditAllocation = maxGroupTieredPackage.creditAllocation + currency = maxGroupTieredPackage.currency + discount = maxGroupTieredPackage.discount + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = maxGroupTieredPackage.invoicingCycleConfiguration + item = maxGroupTieredPackage.item + maxGroupTieredPackageConfig = maxGroupTieredPackage.maxGroupTieredPackageConfig + maximum = maxGroupTieredPackage.maximum + maximumAmount = maxGroupTieredPackage.maximumAmount + metadata = maxGroupTieredPackage.metadata + minimum = maxGroupTieredPackage.minimum + minimumAmount = maxGroupTieredPackage.minimumAmount + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + planPhaseOrder = maxGroupTieredPackage.planPhaseOrder + priceType = maxGroupTieredPackage.priceType + replacesPriceId = maxGroupTieredPackage.replacesPriceId + dimensionalPriceConfiguration = maxGroupTieredPackage.dimensionalPriceConfiguration + licenseType = maxGroupTieredPackage.licenseType + additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -64484,6 +85942,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -64522,21 +86001,21 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } - /** Configuration for matrix_with_display_name pricing */ - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig - ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + /** Configuration for max_group_tiered_package pricing */ + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) /** - * Sets [Builder.matrixWithDisplayNameConfig] to an arbitrary JSON value. + * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. * - * You should usually call [Builder.matrixWithDisplayNameConfig] with a well-typed - * [MatrixWithDisplayNameConfig] value instead. This method is primarily for setting the + * You should usually call [Builder.maxGroupTieredPackageConfig] with a well-typed + * [MaxGroupTieredPackageConfig] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: JsonField - ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -64636,7 +86115,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("matrix_with_display_name") + * JsonValue.from("max_group_tiered_package") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -64736,6 +86215,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -64756,7 +86258,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithDisplayName]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -64776,9 +86278,10 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() - * .matrixWithDisplayNameConfig() + * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -64792,8 +86295,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithDisplayName = - MatrixWithDisplayName( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -64810,9 +86313,10 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), + checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -64824,13 +86328,23 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): MatrixWithDisplayName = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -64849,16 +86363,17 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() - matrixWithDisplayNameConfig().validate() + maxGroupTieredPackageConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("matrix_with_display_name")) { + if (it != JsonValue.from("max_group_tiered_package")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -64867,6 +86382,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -64901,20 +86417,22 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + - (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -65007,6 +86525,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -65159,6 +86687,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -65408,6 +86946,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -65551,6 +87099,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -65683,6 +87241,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -65743,62 +87311,80 @@ private constructor( "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - /** Configuration for matrix_with_display_name pricing */ - class MatrixWithDisplayNameConfig + /** Configuration for max_group_tiered_package pricing */ + class MaxGroupTieredPackageConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val dimension: JsonField, - private val unitAmounts: JsonField>, + private val groupingKey: JsonField, + private val packageSize: JsonField, + private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("dimension") + @JsonProperty("grouping_key") @ExcludeMissing - dimension: JsonField = JsonMissing.of(), - @JsonProperty("unit_amounts") + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("package_size") @ExcludeMissing - unitAmounts: JsonField> = JsonMissing.of(), - ) : this(dimension, unitAmounts, mutableMapOf()) + packageSize: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(groupingKey, packageSize, tiers, mutableMapOf()) /** - * Used to determine the unit rate + * The event property used to group before tiering the group with the highest value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun dimension(): String = dimension.getRequired("dimension") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Apply per unit pricing to each dimension value + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun packageSize(): String = packageSize.getRequired("package_size") + + /** + * Apply tiered pricing to the largest group after grouping with the provided key. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun unitAmounts(): List = unitAmounts.getRequired("unit_amounts") + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns the raw JSON value of [dimension]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [dimension], this method doesn't throw if the JSON field has an unexpected + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("dimension") + @JsonProperty("grouping_key") @ExcludeMissing - fun _dimension(): JsonField = dimension + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [unitAmounts]. + * Returns the raw JSON value of [packageSize]. * - * Unlike [unitAmounts], this method doesn't throw if the JSON field has an unexpected + * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("unit_amounts") + @JsonProperty("package_size") @ExcludeMissing - fun _unitAmounts(): JsonField> = unitAmounts + fun _packageSize(): JsonField = packageSize + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -65816,70 +87402,90 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MatrixWithDisplayNameConfig]. + * [MaxGroupTieredPackageConfig]. * * The following fields are required: * ```java - * .dimension() - * .unitAmounts() + * .groupingKey() + * .packageSize() + * .tiers() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixWithDisplayNameConfig]. */ + /** A builder for [MaxGroupTieredPackageConfig]. */ class Builder internal constructor() { - private var dimension: JsonField? = null - private var unitAmounts: JsonField>? = null + private var groupingKey: JsonField? = null + private var packageSize: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = + internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = apply { - dimension = matrixWithDisplayNameConfig.dimension - unitAmounts = - matrixWithDisplayNameConfig.unitAmounts.map { it.toMutableList() } + groupingKey = maxGroupTieredPackageConfig.groupingKey + packageSize = maxGroupTieredPackageConfig.packageSize + tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } additionalProperties = - matrixWithDisplayNameConfig.additionalProperties.toMutableMap() + maxGroupTieredPackageConfig.additionalProperties.toMutableMap() } - /** Used to determine the unit rate */ - fun dimension(dimension: String) = dimension(JsonField.of(dimension)) + /** + * The event property used to group before tiering the group with the highest value + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.dimension] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.dimension] with a well-typed [String] value + * You should usually call [Builder.groupingKey] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun dimension(dimension: JsonField) = apply { this.dimension = dimension } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** Apply per unit pricing to each dimension value */ - fun unitAmounts(unitAmounts: List) = - unitAmounts(JsonField.of(unitAmounts)) + fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) /** - * Sets [Builder.unitAmounts] to an arbitrary JSON value. + * Sets [Builder.packageSize] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmounts] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * You should usually call [Builder.packageSize] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun unitAmounts(unitAmounts: JsonField>) = apply { - this.unitAmounts = unitAmounts.map { it.toMutableList() } + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize } /** - * Adds a single [UnitAmount] to [unitAmounts]. + * Apply tiered pricing to the largest group after grouping with the provided key. + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addUnitAmount(unitAmount: UnitAmount) = apply { - unitAmounts = - (unitAmounts ?: JsonField.of(mutableListOf())).also { - checkKnown("unitAmounts", it).add(unitAmount) + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) } } @@ -65906,35 +87512,48 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithDisplayNameConfig]. + * Returns an immutable instance of [MaxGroupTieredPackageConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .dimension() - * .unitAmounts() + * .groupingKey() + * .packageSize() + * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig( - checkRequired("dimension", dimension), - checkRequired("unitAmounts", unitAmounts).map { it.toImmutable() }, + fun build(): MaxGroupTieredPackageConfig = + MaxGroupTieredPackageConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("packageSize", packageSize), + checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): MatrixWithDisplayNameConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MaxGroupTieredPackageConfig = apply { if (validated) { return@apply } - dimension() - unitAmounts().forEach { it.validate() } + groupingKey() + packageSize() + tiers().forEach { it.validate() } validated = true } @@ -65954,49 +87573,35 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (dimension.asKnown().isPresent) 1 else 0) + - (unitAmounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (packageSize.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a unit amount item */ - class UnitAmount + /** Configuration for a single tier */ + class Tier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val dimensionValue: JsonField, - private val displayName: JsonField, + private val tierLowerBound: JsonField, private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("dimension_value") - @ExcludeMissing - dimensionValue: JsonField = JsonMissing.of(), - @JsonProperty("display_name") + @JsonProperty("tier_lower_bound") @ExcludeMissing - displayName: JsonField = JsonMissing.of(), + tierLowerBound: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), - ) : this(dimensionValue, displayName, unitAmount, mutableMapOf()) - - /** - * The dimension value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun dimensionValue(): String = dimensionValue.getRequired("dimension_value") + ) : this(tierLowerBound, unitAmount, mutableMapOf()) /** - * Display name for this dimension value - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun displayName(): String = displayName.getRequired("display_name") + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") /** * Per unit amount @@ -66008,24 +87613,14 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [dimensionValue]. - * - * Unlike [dimensionValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dimension_value") - @ExcludeMissing - fun _dimensionValue(): JsonField = dimensionValue - - /** - * Returns the raw JSON value of [displayName]. + * Returns the raw JSON value of [tierLowerBound]. * - * Unlike [displayName], this method doesn't throw if the JSON field has an + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("display_name") + @JsonProperty("tier_lower_bound") @ExcludeMissing - fun _displayName(): JsonField = displayName + fun _tierLowerBound(): JsonField = tierLowerBound /** * Returns the raw JSON value of [unitAmount]. @@ -66052,61 +87647,43 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnitAmount]. + * Returns a mutable builder for constructing an instance of [Tier]. * * The following fields are required: * ```java - * .dimensionValue() - * .displayName() + * .tierLowerBound() * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnitAmount]. */ + /** A builder for [Tier]. */ class Builder internal constructor() { - private var dimensionValue: JsonField? = null - private var displayName: JsonField? = null + private var tierLowerBound: JsonField? = null private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitAmount: UnitAmount) = apply { - dimensionValue = unitAmount.dimensionValue - displayName = unitAmount.displayName - this.unitAmount = unitAmount.unitAmount - additionalProperties = unitAmount.additionalProperties.toMutableMap() - } - - /** The dimension value */ - fun dimensionValue(dimensionValue: String) = - dimensionValue(JsonField.of(dimensionValue)) - - /** - * Sets [Builder.dimensionValue] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionValue] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun dimensionValue(dimensionValue: JsonField) = apply { - this.dimensionValue = dimensionValue + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() } - /** Display name for this dimension value */ - fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) /** - * Sets [Builder.displayName] to an arbitrary JSON value. + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. * - * You should usually call [Builder.displayName] with a well-typed [String] + * You should usually call [Builder.tierLowerBound] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun displayName(displayName: JsonField) = apply { - this.displayName = displayName + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound } /** Per unit amount */ @@ -66146,23 +87723,21 @@ private constructor( } /** - * Returns an immutable instance of [UnitAmount]. + * Returns an immutable instance of [Tier]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .dimensionValue() - * .displayName() + * .tierLowerBound() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnitAmount = - UnitAmount( - checkRequired("dimensionValue", dimensionValue), - checkRequired("displayName", displayName), + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) @@ -66170,13 +87745,22 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitAmount = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Tier = apply { if (validated) { return@apply } - dimensionValue() - displayName() + tierLowerBound() unitAmount() validated = true } @@ -66197,8 +87781,7 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (dimensionValue.asKnown().isPresent) 1 else 0) + - (if (displayName.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -66206,21 +87789,20 @@ private constructor( return true } - return other is UnitAmount && - dimensionValue == other.dimensionValue && - displayName == other.displayName && + return other is Tier && + tierLowerBound == other.tierLowerBound && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(dimensionValue, displayName, unitAmount, additionalProperties) + Objects.hash(tierLowerBound, unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UnitAmount{dimensionValue=$dimensionValue, displayName=$displayName, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -66228,20 +87810,21 @@ private constructor( return true } - return other is MatrixWithDisplayNameConfig && - dimension == other.dimension && - unitAmounts == other.unitAmounts && + return other is MaxGroupTieredPackageConfig && + groupingKey == other.groupingKey && + packageSize == other.packageSize && + tiers == other.tiers && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(dimension, unitAmounts, additionalProperties) + Objects.hash(groupingKey, packageSize, tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayNameConfig{dimension=$dimension, unitAmounts=$unitAmounts, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -66301,159 +87884,434 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object + * Validates that the types of all values in this object match their expected types * recursively. * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - known() + id() + groupingKey() + name() validated = true } @@ -66471,19 +88329,32 @@ 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 = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PriceType && value == other.value + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -66491,7 +88362,7 @@ private constructor( return true } - return other is MatrixWithDisplayName && + return other is MaxGroupTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -66506,9 +88377,10 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && - matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && + maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -66520,6 +88392,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -66539,9 +88412,10 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, - matrixWithDisplayNameConfig, + maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -66553,6 +88427,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -66560,10 +88435,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class GroupedTieredPackage + class ScalableMatrixWithUnitPricing @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -66580,7 +88455,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, - private val groupedTieredPackageConfig: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -66593,7 +88468,10 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val scalableMatrixWithUnitPricingConfig: + JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -66637,9 +88515,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_package_config") + @JsonProperty("invoice_grouping_key") @ExcludeMissing - groupedTieredPackageConfig: JsonField = JsonMissing.of(), + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -66666,10 +88544,17 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + scalableMatrixWithUnitPricingConfig: JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -66685,7 +88570,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredPackageConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -66698,7 +88583,9 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -66794,13 +88681,11 @@ private constructor( fixedPriceQuantity.getOptional("fixed_price_quantity") /** - * Configuration for grouped_tiered_package pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = - groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -66859,7 +88744,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_tiered_package") + * JsonValue.from("scalable_matrix_with_unit_pricing") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -66894,6 +88779,17 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") + /** + * Configuration for scalable_matrix_with_unit_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -66901,6 +88797,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -67032,15 +88937,14 @@ private constructor( fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** - * Returns the raw JSON value of [groupedTieredPackageConfig]. + * Returns the raw JSON value of [invoiceGroupingKey]. * - * Unlike [groupedTieredPackageConfig], this method doesn't throw if the JSON field has an + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouped_tiered_package_config") + @JsonProperty("invoice_grouping_key") @ExcludeMissing - fun _groupedTieredPackageConfig(): JsonField = - groupedTieredPackageConfig + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Returns the raw JSON value of [invoicingCycleConfiguration]. @@ -67145,6 +89049,17 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. + * + * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): JsonField = + scalableMatrixWithUnitPricingConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -67156,6 +89071,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -67171,7 +89095,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java @@ -67189,7 +89114,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredPackageConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -67201,12 +89126,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithUnitPricingConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedTieredPackage]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -67223,7 +89149,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null - private var groupedTieredPackageConfig: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -67231,48 +89157,62 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") + private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { - id = groupedTieredPackage.id - billableMetric = groupedTieredPackage.billableMetric - billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration - billingMode = groupedTieredPackage.billingMode - cadence = groupedTieredPackage.cadence - compositePriceFilters = - groupedTieredPackage.compositePriceFilters.map { it.toMutableList() } - conversionRate = groupedTieredPackage.conversionRate - conversionRateConfig = groupedTieredPackage.conversionRateConfig - createdAt = groupedTieredPackage.createdAt - creditAllocation = groupedTieredPackage.creditAllocation - currency = groupedTieredPackage.currency - discount = groupedTieredPackage.discount - externalPriceId = groupedTieredPackage.externalPriceId - fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity - groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig - invoicingCycleConfiguration = groupedTieredPackage.invoicingCycleConfiguration - item = groupedTieredPackage.item - maximum = groupedTieredPackage.maximum - maximumAmount = groupedTieredPackage.maximumAmount - metadata = groupedTieredPackage.metadata - minimum = groupedTieredPackage.minimum - minimumAmount = groupedTieredPackage.minimumAmount - modelType = groupedTieredPackage.modelType - name = groupedTieredPackage.name - planPhaseOrder = groupedTieredPackage.planPhaseOrder - priceType = groupedTieredPackage.priceType - replacesPriceId = groupedTieredPackage.replacesPriceId - dimensionalPriceConfiguration = groupedTieredPackage.dimensionalPriceConfiguration - additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() - } + internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = + apply { + id = scalableMatrixWithUnitPricing.id + billableMetric = scalableMatrixWithUnitPricing.billableMetric + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + billingMode = scalableMatrixWithUnitPricing.billingMode + cadence = scalableMatrixWithUnitPricing.cadence + compositePriceFilters = + scalableMatrixWithUnitPricing.compositePriceFilters.map { + it.toMutableList() + } + conversionRate = scalableMatrixWithUnitPricing.conversionRate + conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig + createdAt = scalableMatrixWithUnitPricing.createdAt + creditAllocation = scalableMatrixWithUnitPricing.creditAllocation + currency = scalableMatrixWithUnitPricing.currency + discount = scalableMatrixWithUnitPricing.discount + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + item = scalableMatrixWithUnitPricing.item + maximum = scalableMatrixWithUnitPricing.maximum + maximumAmount = scalableMatrixWithUnitPricing.maximumAmount + metadata = scalableMatrixWithUnitPricing.metadata + minimum = scalableMatrixWithUnitPricing.minimum + minimumAmount = scalableMatrixWithUnitPricing.minimumAmount + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + planPhaseOrder = scalableMatrixWithUnitPricing.planPhaseOrder + priceType = scalableMatrixWithUnitPricing.priceType + replacesPriceId = scalableMatrixWithUnitPricing.replacesPriceId + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + licenseType = scalableMatrixWithUnitPricing.licenseType + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -67649,20 +89589,26 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - /** Configuration for grouped_tiered_package pricing */ - fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = - groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) /** - * Sets [Builder.groupedTieredPackageConfig] to an arbitrary JSON value. + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.groupedTieredPackageConfig] with a well-typed - * [GroupedTieredPackageConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: JsonField - ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? @@ -67800,7 +89746,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_tiered_package") + * JsonValue.from("scalable_matrix_with_unit_pricing") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -67877,6 +89823,27 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a + * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig + } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -67900,6 +89867,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -67920,7 +89910,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredPackage]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -67940,7 +89930,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() - * .groupedTieredPackageConfig() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -67952,12 +89942,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTieredPackage = - GroupedTieredPackage( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -67974,7 +89965,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -67987,14 +89978,28 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedTieredPackage = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } @@ -68013,7 +90018,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedTieredPackageConfig().validate() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -68022,7 +90027,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("grouped_tiered_package")) { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -68030,7 +90035,9 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -68065,7 +90072,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -68073,12 +90080,16 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -68171,6 +90182,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -68323,6 +90344,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -68572,6 +90603,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -68715,6 +90756,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -68767,194 +90818,543 @@ private constructor( */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - companion object { + companion object { + + @JvmField val INCLUDES = of("includes") + + @JvmField val EXCLUDES = of("excludes") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmField val INCLUDES = of("includes") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JvmField val EXCLUDES = of("excludes") + companion object { - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } + @JvmField val USAGE_PRICE = of("usage_price") - /** An enum containing [Operator]'s known values. */ - enum class Known { - INCLUDES, - EXCLUDES, - } + @JvmField val FIXED_PRICE = of("fixed_price") - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCLUDES, - EXCLUDES, - /** - * An enum member indicating that [Operator] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + @JvmField val COMPOSITE_PRICE = of("composite_price") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCLUDES -> Value.INCLUDES - EXCLUDES -> Value.EXCLUDES - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCLUDES -> Known.INCLUDES - EXCLUDES -> Known.EXCLUDES - else -> throw OrbInvalidDataException("Unknown Operator: $value") - } + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } + _UNKNOWN, + } - known() - validated = true + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Operator && value == other.value + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + known() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CompositePriceFilter && - field == other.field && - operator == other.operator && - values == other.values && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, operator, values, additionalProperties) + return other is PriceType && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** Configuration for grouped_tiered_package pricing */ - class GroupedTieredPackageConfig + /** Configuration for scalable_matrix_with_unit_pricing pricing */ + class ScalableMatrixWithUnitPricingConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, + private val unitPrice: JsonField, private val groupingKey: JsonField, - private val packageSize: JsonField, - private val tiers: JsonField>, + private val prorate: JsonField, + private val secondDimension: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + matrixScalingFactors: JsonField> = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("package_size") + @JsonProperty("prorate") @ExcludeMissing - packageSize: JsonField = JsonMissing.of(), - @JsonProperty("tiers") + prorate: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension") @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + secondDimension: JsonField = JsonMissing.of(), + ) : this( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + mutableMapOf(), + ) /** - * The event property used to group before tiering + * Used to determine the unit rate * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") /** + * Apply a scaling factor to each dimension + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun packageSize(): String = packageSize.getRequired("package_size") + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") /** - * Apply tiered pricing after rounding up the quantity to the package size. Tiers are - * defined using exclusive lower bounds. + * The final unit price to rate against the output of the matrix * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun unitPrice(): String = unitPrice.getRequired("unit_price") + + /** + * The property used to group this price + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * If true, the unit price will be prorated to the billing period + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prorate(): Optional = prorate.getOptional("prorate") + + /** + * Used to determine the unit rate (optional) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixScalingFactors]. + * + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_scaling_factors") + @ExcludeMissing + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice /** * Returns the raw JSON value of [groupingKey]. @@ -68967,21 +91367,21 @@ private constructor( fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [packageSize]. + * Returns the raw JSON value of [prorate]. * - * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("package_size") - @ExcludeMissing - fun _packageSize(): JsonField = packageSize + @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate /** - * Returns the raw JSON value of [tiers]. + * Returns the raw JSON value of [secondDimension]. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -68999,89 +91399,163 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedTieredPackageConfig]. + * [ScalableMatrixWithUnitPricingConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .packageSize() - * .tiers() + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedTieredPackageConfig]. */ + /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var packageSize: JsonField? = null - private var tiers: JsonField>? = null + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = + null + private var unitPrice: JsonField? = null + private var groupingKey: JsonField = JsonMissing.of() + private var prorate: JsonField = JsonMissing.of() + private var secondDimension: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { - groupingKey = groupedTieredPackageConfig.groupingKey - packageSize = groupedTieredPackageConfig.packageSize - tiers = groupedTieredPackageConfig.tiers.map { it.toMutableList() } + internal fun from( + scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig + ) = apply { + firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice + groupingKey = scalableMatrixWithUnitPricingConfig.groupingKey + prorate = scalableMatrixWithUnitPricingConfig.prorate + secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension additionalProperties = - groupedTieredPackageConfig.additionalProperties.toMutableMap() + scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() } - /** The event property used to group before tiering */ - fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + /** Used to determine the unit rate */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.firstDimension] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] value + * You should usually call [Builder.firstDimension] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension } - fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) /** - * Sets [Builder.packageSize] to an arbitrary JSON value. + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. * - * You should usually call [Builder.packageSize] with a well-typed [String] value + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + /** The final unit price to rate against the output of the matrix */ + fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** The property used to group this price */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** If true, the unit price will be prorated to the billing period */ + fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + /** - * Apply tiered pricing after rounding up the quantity to the package size. Tiers - * are defined using exclusive lower bounds. + * Alias for [Builder.prorate]. + * + * This unboxed primitive overload exists for backwards compatibility. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) + + /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ + fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.prorate] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` value + * You should usually call [Builder.prorate] with a well-typed [Boolean] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + fun prorate(prorate: JsonField) = apply { this.prorate = prorate } + + /** Used to determine the unit rate (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) /** - * Adds a single [Tier] to [tiers]. + * Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.secondDimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension } fun additionalProperties(additionalProperties: Map) = apply { @@ -69107,38 +91581,56 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredPackageConfig]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .groupingKey() - * .packageSize() - * .tiers() + * .firstDimension() + * .matrixScalingFactors() + * .unitPrice() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("packageSize", packageSize), - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): ScalableMatrixWithUnitPricingConfig = + ScalableMatrixWithUnitPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("unitPrice", unitPrice), + groupingKey, + prorate, + secondDimension, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedTieredPackageConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ScalableMatrixWithUnitPricingConfig = apply { if (validated) { return@apply } + firstDimension() + matrixScalingFactors().forEach { it.validate() } + unitPrice() groupingKey() - packageSize() - tiers().forEach { it.validate() } + prorate() + secondDimension() validated = true } @@ -69158,64 +91650,88 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (packageSize.asKnown().isPresent) 1 else 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (prorate.asKnown().isPresent) 1 else 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) - /** Configuration for a single tier */ - class Tier + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val perUnit: JsonField, - private val tierLowerBound: JsonField, + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("per_unit") + @JsonProperty("first_dimension_value") @ExcludeMissing - perUnit: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(perUnit, tierLowerBound, mutableMapOf()) + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) /** - * Per package - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun perUnit(): String = perUnit.getRequired("per_unit") + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") /** - * Returns the raw JSON value of [perUnit]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. * - * Unlike [perUnit], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("per_unit") + @JsonProperty("first_dimension_value") @ExcludeMissing - fun _perUnit(): JsonField = perUnit + fun _firstDimensionValue(): JsonField = firstDimensionValue /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns the raw JSON value of [scalingFactor]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("scaling_factor") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -69232,55 +91748,82 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tier]. + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. * * The following fields are required: * ```java - * .perUnit() - * .tierLowerBound() + * .firstDimensionValue() + * .scalingFactor() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Tier]. */ + /** A builder for [MatrixScalingFactor]. */ class Builder internal constructor() { - private var perUnit: JsonField? = null - private var tierLowerBound: JsonField? = null + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tier: Tier) = apply { - perUnit = tier.perUnit - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() } - /** Per package */ - fun perUnit(perUnit: String) = perUnit(JsonField.of(perUnit)) + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) /** - * Sets [Builder.perUnit] to an arbitrary JSON value. + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. * - * You should usually call [Builder.perUnit] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.firstDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun perUnit(perUnit: JsonField) = apply { this.perUnit = perUnit } + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.scalingFactor] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * You should usually call [Builder.scalingFactor] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue } fun additionalProperties(additionalProperties: Map) = apply { @@ -69306,35 +91849,47 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [MatrixScalingFactor]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .perUnit() - * .tierLowerBound() + * .firstDimensionValue() + * .scalingFactor() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( - checkRequired("perUnit", perUnit), - checkRequired("tierLowerBound", tierLowerBound), + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Tier = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixScalingFactor = apply { if (validated) { return@apply } - perUnit() - tierLowerBound() + firstDimensionValue() + scalingFactor() + secondDimensionValue() validated = true } @@ -69354,28 +91909,35 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (perUnit.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Tier && - perUnit == other.perUnit && - tierLowerBound == other.tierLowerBound && + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(perUnit, tierLowerBound, additionalProperties) + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{perUnit=$perUnit, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -69383,57 +91945,192 @@ private constructor( return true } - return other is GroupedTieredPackageConfig && + return other is ScalableMatrixWithUnitPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && + unitPrice == other.unitPrice && groupingKey == other.groupingKey && - packageSize == other.packageSize && - tiers == other.tiers && + prorate == other.prorate && + secondDimension == other.secondDimension && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + Objects.hash( + firstDimension, + matrixScalingFactors, + unitPrice, + groupingKey, + prorate, + secondDimension, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, groupingKey=$groupingKey, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. */ - class Metadata - @JsonCreator + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [LicenseType]. */ class Builder internal constructor() { + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -69457,159 +92154,48 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object + * Validates that the types of all values in this object match their expected types * recursively. * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - known() + id() + groupingKey() + name() validated = true } @@ -69627,19 +92213,32 @@ 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 = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PriceType && value == other.value + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -69647,7 +92246,7 @@ private constructor( return true } - return other is GroupedTieredPackage && + return other is ScalableMatrixWithUnitPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -69662,7 +92261,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && - groupedTieredPackageConfig == other.groupedTieredPackageConfig && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -69675,7 +92274,9 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -69695,7 +92296,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, - groupedTieredPackageConfig, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -69708,7 +92309,9 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -69716,10 +92319,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class MaxGroupTieredPackage + class ScalableMatrixWithTieredPricing @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -69736,9 +92339,9 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, - private val maxGroupTieredPackageConfig: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, @@ -69749,7 +92352,10 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, + private val scalableMatrixWithTieredPricingConfig: + JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -69793,13 +92399,13 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("item") @ExcludeMissing item: JsonField = JsonMissing.of(), - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - maxGroupTieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -69822,10 +92428,18 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -69841,9 +92455,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, - maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -69854,7 +92468,9 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -69949,6 +92565,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -69965,15 +92588,6 @@ private constructor( */ fun item(): ItemSlim = item.getRequired("item") - /** - * Configuration for max_group_tiered_package pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = - maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -70015,7 +92629,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("max_group_tiered_package") + * JsonValue.from("scalable_matrix_with_tiered_pricing") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -70050,6 +92664,17 @@ private constructor( */ fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") + /** + * Configuration for scalable_matrix_with_tiered_pricing pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -70057,6 +92682,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -70187,6 +92821,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -70205,17 +92849,6 @@ private constructor( */ @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - /** - * Returns the raw JSON value of [maxGroupTieredPackageConfig]. - * - * Unlike [maxGroupTieredPackageConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - fun _maxGroupTieredPackageConfig(): JsonField = - maxGroupTieredPackageConfig - /** * Returns the raw JSON value of [maximum]. * @@ -70301,6 +92934,17 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId + /** + * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. + * + * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): + JsonField = scalableMatrixWithTieredPricingConfig + /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -70312,6 +92956,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -70327,7 +92980,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MaxGroupTieredPackage]. + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java @@ -70345,9 +92999,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() - * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -70357,12 +93011,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithTieredPricingConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackage]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -70379,56 +93034,70 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null - private var maxGroupTieredPackageConfig: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") + private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { - id = maxGroupTieredPackage.id - billableMetric = maxGroupTieredPackage.billableMetric - billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration - billingMode = maxGroupTieredPackage.billingMode - cadence = maxGroupTieredPackage.cadence - compositePriceFilters = - maxGroupTieredPackage.compositePriceFilters.map { it.toMutableList() } - conversionRate = maxGroupTieredPackage.conversionRate - conversionRateConfig = maxGroupTieredPackage.conversionRateConfig - createdAt = maxGroupTieredPackage.createdAt - creditAllocation = maxGroupTieredPackage.creditAllocation - currency = maxGroupTieredPackage.currency - discount = maxGroupTieredPackage.discount - externalPriceId = maxGroupTieredPackage.externalPriceId - fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity - invoicingCycleConfiguration = maxGroupTieredPackage.invoicingCycleConfiguration - item = maxGroupTieredPackage.item - maxGroupTieredPackageConfig = maxGroupTieredPackage.maxGroupTieredPackageConfig - maximum = maxGroupTieredPackage.maximum - maximumAmount = maxGroupTieredPackage.maximumAmount - metadata = maxGroupTieredPackage.metadata - minimum = maxGroupTieredPackage.minimum - minimumAmount = maxGroupTieredPackage.minimumAmount - modelType = maxGroupTieredPackage.modelType - name = maxGroupTieredPackage.name - planPhaseOrder = maxGroupTieredPackage.planPhaseOrder - priceType = maxGroupTieredPackage.priceType - replacesPriceId = maxGroupTieredPackage.replacesPriceId - dimensionalPriceConfiguration = maxGroupTieredPackage.dimensionalPriceConfiguration - additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() - } + internal fun from(scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing) = + apply { + id = scalableMatrixWithTieredPricing.id + billableMetric = scalableMatrixWithTieredPricing.billableMetric + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + billingMode = scalableMatrixWithTieredPricing.billingMode + cadence = scalableMatrixWithTieredPricing.cadence + compositePriceFilters = + scalableMatrixWithTieredPricing.compositePriceFilters.map { + it.toMutableList() + } + conversionRate = scalableMatrixWithTieredPricing.conversionRate + conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig + createdAt = scalableMatrixWithTieredPricing.createdAt + creditAllocation = scalableMatrixWithTieredPricing.creditAllocation + currency = scalableMatrixWithTieredPricing.currency + discount = scalableMatrixWithTieredPricing.discount + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + item = scalableMatrixWithTieredPricing.item + maximum = scalableMatrixWithTieredPricing.maximum + maximumAmount = scalableMatrixWithTieredPricing.maximumAmount + metadata = scalableMatrixWithTieredPricing.metadata + minimum = scalableMatrixWithTieredPricing.minimum + minimumAmount = scalableMatrixWithTieredPricing.minimumAmount + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name + planPhaseOrder = scalableMatrixWithTieredPricing.planPhaseOrder + priceType = scalableMatrixWithTieredPricing.priceType + replacesPriceId = scalableMatrixWithTieredPricing.replacesPriceId + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + licenseType = scalableMatrixWithTieredPricing.licenseType + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -70805,6 +93474,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -70843,22 +93533,6 @@ private constructor( */ fun item(item: JsonField) = apply { this.item = item } - /** Configuration for max_group_tiered_package pricing */ - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig - ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) - - /** - * Sets [Builder.maxGroupTieredPackageConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.maxGroupTieredPackageConfig] with a well-typed - * [MaxGroupTieredPackageConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: JsonField - ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - @Deprecated("deprecated") fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) @@ -70957,7 +93631,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("max_group_tiered_package") + * JsonValue.from("scalable_matrix_with_tiered_pricing") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -71034,6 +93708,28 @@ private constructor( this.replacesPriceId = replacesPriceId } + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + /** + * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with a + * well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: + JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig + } + fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -71057,6 +93753,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -71077,7 +93796,7 @@ private constructor( } /** - * Returns an immutable instance of [MaxGroupTieredPackage]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -71097,9 +93816,9 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() - * .maxGroupTieredPackageConfig() * .maximum() * .maximumAmount() * .metadata() @@ -71109,12 +93828,13 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() + * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): MaxGroupTieredPackage = - MaxGroupTieredPackage( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -71131,9 +93851,9 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -71144,14 +93864,28 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): MaxGroupTieredPackage = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } @@ -71170,16 +93904,16 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() - maxGroupTieredPackageConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("max_group_tiered_package")) { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -71187,7 +93921,9 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() + scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -71222,20 +93958,24 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + - (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -71328,6 +94068,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -71480,6 +94230,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -71729,6 +94489,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -71872,6 +94642,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -72002,110 +94782,387 @@ private constructor( OrbInvalidDataException("Value is not a String") } - private var validated: Boolean = false + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - fun validate(): Operator = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - known() - validated = true + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + known() + validated = true + } - return other is Operator && value == other.value + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CompositePriceFilter && - field == other.field && - operator == other.operator && - values == other.values && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, operator, values, additionalProperties) + return other is PriceType && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** Configuration for max_group_tiered_package pricing */ - class MaxGroupTieredPackageConfig + /** Configuration for scalable_matrix_with_tiered_pricing pricing */ + class ScalableMatrixWithTieredPricingConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val packageSize: JsonField, + private val firstDimension: JsonField, + private val matrixScalingFactors: JsonField>, private val tiers: JsonField>, + private val secondDimension: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("first_dimension") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("package_size") + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_scaling_factors") @ExcludeMissing - packageSize: JsonField = JsonMissing.of(), + matrixScalingFactors: JsonField> = JsonMissing.of(), @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), - ) : this(groupingKey, packageSize, tiers, mutableMapOf()) + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + ) : this(firstDimension, matrixScalingFactors, tiers, secondDimension, mutableMapOf()) /** - * The event property used to group before tiering the group with the highest value + * Used for the scalable matrix first dimension * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") /** + * Apply a scaling factor to each dimension + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun packageSize(): String = packageSize.getRequired("package_size") + fun matrixScalingFactors(): List = + matrixScalingFactors.getRequired("matrix_scaling_factors") /** - * Apply tiered pricing to the largest group after grouping with the provided key. - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -72113,24 +95170,33 @@ private constructor( fun tiers(): List = tiers.getRequired("tiers") /** - * Returns the raw JSON value of [groupingKey]. + * Used for the scalable matrix second dimension (optional) * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("grouping_key") + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _firstDimension(): JsonField = firstDimension /** - * Returns the raw JSON value of [packageSize]. + * Returns the raw JSON value of [matrixScalingFactors]. * - * Unlike [packageSize], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("package_size") + @JsonProperty("matrix_scaling_factors") @ExcludeMissing - fun _packageSize(): JsonField = packageSize + fun _matrixScalingFactors(): JsonField> = matrixScalingFactors /** * Returns the raw JSON value of [tiers]. @@ -72139,6 +95205,16 @@ private constructor( */ @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -72155,172 +95231,510 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MaxGroupTieredPackageConfig]. + * [ScalableMatrixWithTieredPricingConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .packageSize() + * .firstDimension() + * .matrixScalingFactors() * .tiers() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackageConfig]. */ - class Builder internal constructor() { + /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ + class Builder internal constructor() { + + private var firstDimension: JsonField? = null + private var matrixScalingFactors: JsonField>? = + null + private var tiers: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + ) = apply { + firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension + matrixScalingFactors = + scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { + it.toMutableList() + } + tiers = scalableMatrixWithTieredPricingConfig.tiers.map { it.toMutableList() } + secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension + additionalProperties = + scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() + } + + /** Used for the scalable matrix first dimension */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Apply a scaling factor to each dimension */ + fun matrixScalingFactors(matrixScalingFactors: List) = + matrixScalingFactors(JsonField.of(matrixScalingFactors)) + + /** + * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixScalingFactors] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixScalingFactors( + matrixScalingFactors: JsonField> + ) = apply { + this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { + matrixScalingFactors = + (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) + } + } + + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + /** Used for the scalable matrix second dimension (optional) */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimension() + * .matrixScalingFactors() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ScalableMatrixWithTieredPricingConfig = + ScalableMatrixWithTieredPricingConfig( + checkRequired("firstDimension", firstDimension), + checkRequired("matrixScalingFactors", matrixScalingFactors).map { + it.toImmutable() + }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + secondDimension, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ScalableMatrixWithTieredPricingConfig = apply { + if (validated) { + return@apply + } + + firstDimension() + matrixScalingFactors().forEach { it.validate() } + tiers().forEach { it.validate() } + secondDimension() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + /** Configuration for a single matrix scaling factor */ + class MatrixScalingFactor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val scalingFactor: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("scaling_factor") + @ExcludeMissing + scalingFactor: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [scalingFactor]. + * + * Unlike [scalingFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("scaling_factor") + @ExcludeMissing + fun _scalingFactor(): JsonField = scalingFactor + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixScalingFactor]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixScalingFactor]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var scalingFactor: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { + firstDimensionValue = matrixScalingFactor.firstDimensionValue + scalingFactor = matrixScalingFactor.scalingFactor + secondDimensionValue = matrixScalingFactor.secondDimensionValue + additionalProperties = + matrixScalingFactor.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } + + fun scalingFactor(scalingFactor: String) = + scalingFactor(JsonField.of(scalingFactor)) + + /** + * Sets [Builder.scalingFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.scalingFactor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun scalingFactor(scalingFactor: JsonField) = apply { + this.scalingFactor = scalingFactor + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) - private var groupingKey: JsonField? = null - private var packageSize: JsonField? = null - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) - @JvmSynthetic - internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = - apply { - groupingKey = maxGroupTieredPackageConfig.groupingKey - packageSize = maxGroupTieredPackageConfig.packageSize - tiers = maxGroupTieredPackageConfig.tiers.map { it.toMutableList() } - additionalProperties = - maxGroupTieredPackageConfig.additionalProperties.toMutableMap() + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue } - /** - * The event property used to group before tiering the group with the highest value - */ - fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun packageSize(packageSize: String) = packageSize(JsonField.of(packageSize)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * Sets [Builder.packageSize] to an arbitrary JSON value. - * - * You should usually call [Builder.packageSize] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Apply tiered pricing to the largest group after grouping with the provided key. - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + /** + * Returns an immutable instance of [MatrixScalingFactor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .scalingFactor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixScalingFactor = + MatrixScalingFactor( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("scalingFactor", scalingFactor), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) } + private var validated: Boolean = false + /** - * Adds a single [Tier] to [tiers]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * @throws IllegalStateException if the field was previously set to a non-list. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): MatrixScalingFactor = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + firstDimensionValue() + scalingFactor() + secondDimensionValue() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [MaxGroupTieredPackageConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .packageSize() - * .tiers() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("packageSize", packageSize), - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (scalingFactor.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): MaxGroupTieredPackageConfig = apply { - if (validated) { - return@apply + return other is MatrixScalingFactor && + firstDimensionValue == other.firstDimensionValue && + scalingFactor == other.scalingFactor && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties } - groupingKey() - packageSize() - tiers().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + scalingFactor, + secondDimensionValue, + additionalProperties, + ) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (packageSize.asKnown().isPresent) 1 else 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun hashCode(): Int = hashCode - /** Configuration for a single tier */ + override fun toString() = + "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single tier entry with business logic */ class Tier @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -72347,8 +95761,6 @@ private constructor( fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") /** - * Per unit amount - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). @@ -72429,7 +95841,6 @@ private constructor( this.tierLowerBound = tierLowerBound } - /** Per unit amount */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -72488,6 +95899,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -72543,57 +95964,188 @@ private constructor( return true } - return other is MaxGroupTieredPackageConfig && - groupingKey == other.groupingKey && - packageSize == other.packageSize && + return other is ScalableMatrixWithTieredPricingConfig && + firstDimension == other.firstDimension && + matrixScalingFactors == other.matrixScalingFactors && tiers == other.tiers && + secondDimension == other.secondDimension && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(groupingKey, packageSize, tiers, additionalProperties) + Objects.hash( + firstDimension, + matrixScalingFactors, + tiers, + secondDimension, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackageConfig{groupingKey=$groupingKey, packageSize=$packageSize, tiers=$tiers, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" } /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. */ - class Metadata - @JsonCreator + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Metadata]. */ + /** A builder for [LicenseType]. */ class Builder internal constructor() { + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -72617,159 +96169,48 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object + * Validates that the types of all values in this object match their expected types * recursively. * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - known() + id() + groupingKey() + name() validated = true } @@ -72787,19 +96228,32 @@ 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 = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PriceType && value == other.value + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int = hashCode - override fun toString() = value.toString() + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -72807,7 +96261,7 @@ private constructor( return true } - return other is MaxGroupTieredPackage && + return other is ScalableMatrixWithTieredPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -72822,9 +96276,9 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && - maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && @@ -72835,7 +96289,10 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && + scalableMatrixWithTieredPricingConfig == + other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -72855,9 +96312,9 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, - maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, @@ -72868,7 +96325,9 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, + scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -72876,10 +96335,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class ScalableMatrixWithUnitPricing + class CumulativeGroupedBulk @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -72892,10 +96351,12 @@ private constructor( private val conversionRateConfig: JsonField, private val createdAt: JsonField, private val creditAllocation: JsonField, + private val cumulativeGroupedBulkConfig: JsonField, private val currency: JsonField, private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -72908,9 +96369,8 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val scalableMatrixWithUnitPricingConfig: - JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -72942,6 +96402,9 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + cumulativeGroupedBulkConfig: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -72954,6 +96417,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -72980,14 +96446,13 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - scalableMatrixWithUnitPricingConfig: JsonField = - JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -72999,10 +96464,12 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedBulkConfig, currency, discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -73015,8 +96482,8 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -73085,6 +96552,15 @@ private constructor( fun creditAllocation(): Optional = creditAllocation.getOptional("credit_allocation") + /** + * Configuration for cumulative_grouped_bulk pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -73111,6 +96587,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -73168,7 +96651,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("scalable_matrix_with_unit_pricing") + * JsonValue.from("cumulative_grouped_bulk") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -73204,22 +96687,20 @@ private constructor( fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") /** - * Configuration for scalable_matrix_with_unit_pricing pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingConfig.getRequired( - "scalable_matrix_with_unit_pricing_config" - ) + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + fun licenseType(): Optional = licenseType.getOptional("license_type") /** * Returns the raw JSON value of [id]. @@ -73314,6 +96795,17 @@ private constructor( @ExcludeMissing fun _creditAllocation(): JsonField = creditAllocation + /** + * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * + * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + /** * Returns the raw JSON value of [currency]. * @@ -73351,6 +96843,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -73454,17 +96956,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [scalableMatrixWithUnitPricingConfig]. - * - * Unlike [scalableMatrixWithUnitPricingConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithUnitPricingConfig(): JsonField = - scalableMatrixWithUnitPricingConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -73476,6 +96967,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -73491,8 +96991,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithUnitPricing]. + * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. * * The following fields are required: * ```java @@ -73506,10 +97005,12 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() + * .cumulativeGroupedBulkConfig() * .currency() * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -73521,13 +97022,12 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithUnitPricingConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ScalableMatrixWithUnitPricing]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -73540,10 +97040,12 @@ private constructor( private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null private var creditAllocation: JsonField? = null + private var cumulativeGroupedBulkConfig: JsonField? = null private var currency: JsonField? = null private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -73551,1228 +97053,1846 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_unit_pricing") + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var scalableMatrixWithUnitPricingConfig: - JsonField? = - null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + id = cumulativeGroupedBulk.id + billableMetric = cumulativeGroupedBulk.billableMetric + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + billingMode = cumulativeGroupedBulk.billingMode + cadence = cumulativeGroupedBulk.cadence + compositePriceFilters = + cumulativeGroupedBulk.compositePriceFilters.map { it.toMutableList() } + conversionRate = cumulativeGroupedBulk.conversionRate + conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig + createdAt = cumulativeGroupedBulk.createdAt + creditAllocation = cumulativeGroupedBulk.creditAllocation + cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig + currency = cumulativeGroupedBulk.currency + discount = cumulativeGroupedBulk.discount + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration + item = cumulativeGroupedBulk.item + maximum = cumulativeGroupedBulk.maximum + maximumAmount = cumulativeGroupedBulk.maximumAmount + metadata = cumulativeGroupedBulk.metadata + minimum = cumulativeGroupedBulk.minimum + minimumAmount = cumulativeGroupedBulk.minimumAmount + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + planPhaseOrder = cumulativeGroupedBulk.planPhaseOrder + priceType = cumulativeGroupedBulk.priceType + replacesPriceId = cumulativeGroupedBulk.replacesPriceId + dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration + licenseType = cumulativeGroupedBulk.licenseType + additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTiny?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.getOrNull()) + + /** + * Sets [Builder.billableMetric] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetric] with a well-typed + * [BillableMetricTiny] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = + billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [BillingCycleConfiguration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + + /** + * Sets [Builder.billingMode] to an arbitrary JSON value. + * + * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingMode(billingMode: JsonField) = apply { + this.billingMode = billingMode + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun compositePriceFilters(compositePriceFilters: List?) = + compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + + /** + * Alias for calling [Builder.compositePriceFilters] with + * `compositePriceFilters.orElse(null)`. + */ + fun compositePriceFilters(compositePriceFilters: Optional>) = + compositePriceFilters(compositePriceFilters.getOrNull()) + + /** + * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.compositePriceFilters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compositePriceFilters( + compositePriceFilters: JsonField> + ) = apply { + this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + } + + /** + * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { + compositePriceFilters = + (compositePriceFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("compositePriceFilters", it).add(compositePriceFilter) + } + } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = apply { - id = scalableMatrixWithUnitPricing.id - billableMetric = scalableMatrixWithUnitPricing.billableMetric - billingCycleConfiguration = - scalableMatrixWithUnitPricing.billingCycleConfiguration - billingMode = scalableMatrixWithUnitPricing.billingMode - cadence = scalableMatrixWithUnitPricing.cadence - compositePriceFilters = - scalableMatrixWithUnitPricing.compositePriceFilters.map { - it.toMutableList() - } - conversionRate = scalableMatrixWithUnitPricing.conversionRate - conversionRateConfig = scalableMatrixWithUnitPricing.conversionRateConfig - createdAt = scalableMatrixWithUnitPricing.createdAt - creditAllocation = scalableMatrixWithUnitPricing.creditAllocation - currency = scalableMatrixWithUnitPricing.currency - discount = scalableMatrixWithUnitPricing.discount - externalPriceId = scalableMatrixWithUnitPricing.externalPriceId - fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity - invoicingCycleConfiguration = - scalableMatrixWithUnitPricing.invoicingCycleConfiguration - item = scalableMatrixWithUnitPricing.item - maximum = scalableMatrixWithUnitPricing.maximum - maximumAmount = scalableMatrixWithUnitPricing.maximumAmount - metadata = scalableMatrixWithUnitPricing.metadata - minimum = scalableMatrixWithUnitPricing.minimum - minimumAmount = scalableMatrixWithUnitPricing.minimumAmount - modelType = scalableMatrixWithUnitPricing.modelType - name = scalableMatrixWithUnitPricing.name - planPhaseOrder = scalableMatrixWithUnitPricing.planPhaseOrder - priceType = scalableMatrixWithUnitPricing.priceType - replacesPriceId = scalableMatrixWithUnitPricing.replacesPriceId - scalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig - dimensionalPriceConfiguration = - scalableMatrixWithUnitPricing.dimensionalPriceConfiguration - additionalProperties = - scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + this.conversionRateConfig = conversionRateConfig } - fun id(id: String) = id(JsonField.of(id)) + /** + * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + .tieredConfig(tieredConfig) + .build() + ) + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: Allocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + /** + * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. + */ + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.getOrNull()) + + /** + * Sets [Builder.creditAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + /** Configuration for cumulative_grouped_bulk pricing */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + /** + * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedBulkConfig] with a well-typed + * [CumulativeGroupedBulkConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + @Deprecated("deprecated") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ + @Deprecated("deprecated") + fun discount(discount: Optional) = discount(discount.getOrNull()) + + /** + * Sets [Builder.discount] to an arbitrary JSON value. + * + * You should usually call [Builder.discount] with a well-typed [Discount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun discount(discount: JsonField) = apply { this.discount = discount } + + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + @Deprecated("deprecated") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * PercentageDiscount.builder() + * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun percentageDiscount(percentageDiscount: Double) = + discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ + @Deprecated("deprecated") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ + @Deprecated("deprecated") + fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + + /** + * Alias for calling [discount] with the following: + * ```java + * UsageDiscount.builder() + * .discountType(UsageDiscount.DiscountType.USAGE) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun usageDiscount(usageDiscount: Double) = + discount( + UsageDiscount.builder() + .discountType(UsageDiscount.DiscountType.USAGE) + .usageDiscount(usageDiscount) + .build() + ) + + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + @Deprecated("deprecated") + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * Alias for calling [discount] with the following: + * ```java + * AmountDiscount.builder() + * .discountType(AmountDiscount.DiscountType.AMOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + @Deprecated("deprecated") + fun amountDiscount(amountDiscount: String) = + discount( + AmountDiscount.builder() + .discountType(AmountDiscount.DiscountType.AMOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.externalPriceId] to an arbitrary JSON value. * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun id(id: JsonField) = apply { this.id = id } + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun billableMetric(billableMetric: BillableMetricTiny?) = - billableMetric(JsonField.ofNullable(billableMetric)) + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** Alias for calling [Builder.billableMetric] with `billableMetric.orElse(null)`. */ - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.getOrNull()) + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) /** - * Sets [Builder.billableMetric] to an arbitrary JSON value. + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. * - * You should usually call [Builder.billableMetric] with a well-typed - * [BillableMetricTiny] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed * [BillingCycleConfiguration] value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun billingMode(billingMode: BillingMode) = billingMode(JsonField.of(billingMode)) + /** + * A minimal representation of an Item containing only the essential identifying + * information. + */ + fun item(item: ItemSlim) = item(JsonField.of(item)) /** - * Sets [Builder.billingMode] to an arbitrary JSON value. + * Sets [Builder.item] to an arbitrary JSON value. * - * You should usually call [Builder.billingMode] with a well-typed [BillingMode] value + * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun item(item: JsonField) = apply { this.item = item } + + @Deprecated("deprecated") + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ + @Deprecated("deprecated") + fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + + /** + * Sets [Builder.maximum] to an arbitrary JSON value. + * + * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun billingMode(billingMode: JsonField) = apply { - this.billingMode = billingMode + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * Sets [Builder.cadence] to an arbitrary JSON value. + * Sets [Builder.metadata] to an arbitrary JSON value. * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun compositePriceFilters(compositePriceFilters: List?) = - compositePriceFilters(JsonField.ofNullable(compositePriceFilters)) + @Deprecated("deprecated") + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ + @Deprecated("deprecated") + fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) /** - * Alias for calling [Builder.compositePriceFilters] with - * `compositePriceFilters.orElse(null)`. + * Sets [Builder.minimum] to an arbitrary JSON value. + * + * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun compositePriceFilters(compositePriceFilters: Optional>) = - compositePriceFilters(compositePriceFilters.getOrNull()) + @Deprecated("deprecated") + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) /** - * Sets [Builder.compositePriceFilters] to an arbitrary JSON value. + * Sets [Builder.minimumAmount] to an arbitrary JSON value. * - * You should usually call [Builder.compositePriceFilters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun compositePriceFilters( - compositePriceFilters: JsonField> - ) = apply { - this.compositePriceFilters = compositePriceFilters.map { it.toMutableList() } + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } /** - * Adds a single [CompositePriceFilter] to [compositePriceFilters]. + * Sets the field to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * 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 addCompositePriceFilter(compositePriceFilter: CompositePriceFilter) = apply { - compositePriceFilters = - (compositePriceFilters ?: JsonField.of(mutableListOf())).also { - checkKnown("compositePriceFilters", it).add(compositePriceFilter) - } - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + fun name(name: String) = name(JsonField.of(name)) /** - * Alias for [Builder.conversionRate]. + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** + * Alias for [Builder.planPhaseOrder]. * * This unboxed primitive overload exists for backwards compatibility. */ - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.getOrNull()) /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. + * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. * - * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder } - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. + * Sets [Builder.priceType] to an arbitrary JSON value. + * + * You should usually call [Builder.priceType] with a well-typed [PriceType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * The price id this price replaces. This price will take the place of the replaced + * price in plan version migrations. + */ + fun replacesPriceId(replacesPriceId: String?) = + replacesPriceId(JsonField.ofNullable(replacesPriceId)) + + /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ + fun replacesPriceId(replacesPriceId: Optional) = + replacesPriceId(replacesPriceId.getOrNull()) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun conversionRateConfig(conversionRateConfig: JsonField) = - apply { - this.conversionRateConfig = conversionRateConfig - } + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfiguration? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) /** - * Alias for calling [conversionRateConfig] with `ConversionRateConfig.ofUnit(unit)`. + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [DimensionalPriceConfiguration] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - .unitConfig(unitConfig) - .build() - ) + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) /** - * Alias for calling [conversionRateConfig] with the following: + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedBulk]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .billingMode() + * .cadence() + * .compositePriceFilters() + * .conversionRate() + * .conversionRateConfig() + * .createdAt() + * .creditAllocation() + * .cumulativeGroupedBulkConfig() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoiceGroupingKey() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .planPhaseOrder() + * .priceType() + * .replacesPriceId() * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - .tieredConfig(tieredConfig) - .build() + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("billingMode", billingMode), + checkRequired("cadence", cadence), + checkRequired("compositePriceFilters", compositePriceFilters).map { + it.toImmutable() + }, + checkRequired("conversionRate", conversionRate), + checkRequired("conversionRateConfig", conversionRateConfig), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + modelType, + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("replacesPriceId", replacesPriceId), + dimensionalPriceConfiguration, + licenseType, + additionalProperties.toMutableMap(), ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CumulativeGroupedBulk = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + billingMode().validate() + cadence().validate() + compositePriceFilters().ifPresent { it.forEach { it.validate() } } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + createdAt() + creditAllocation().ifPresent { it.validate() } + cumulativeGroupedBulkConfig().validate() + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + planPhaseOrder() + priceType().validate() + replacesPriceId() + dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (billingMode.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (discount.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (item.asKnown().getOrNull()?.validity() ?: 0) + + (maximum.asKnown().getOrNull()?.validity() ?: 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (minimum.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + + (priceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + class BillingMode @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Sets [Builder.createdAt] to an arbitrary JSON value. + * Returns this class instance's raw value. * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun creditAllocation(creditAllocation: Allocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) + companion object { - /** - * Alias for calling [Builder.creditAllocation] with `creditAllocation.orElse(null)`. - */ - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.getOrNull()) + @JvmField val IN_ADVANCE = of("in_advance") - /** - * Sets [Builder.creditAllocation] to an arbitrary JSON value. - * - * You should usually call [Builder.creditAllocation] with a well-typed [Allocation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation + @JvmField val IN_ARREAR = of("in_arrear") + + @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) } - fun currency(currency: String) = currency(JsonField.of(currency)) + /** An enum containing [BillingMode]'s known values. */ + enum class Known { + IN_ADVANCE, + IN_ARREAR, + } /** - * Sets [Builder.currency] to an arbitrary JSON value. + * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * An instance of [BillingMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - @Deprecated("deprecated") - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - /** Alias for calling [Builder.discount] with `discount.orElse(null)`. */ - @Deprecated("deprecated") - fun discount(discount: Optional) = discount(discount.getOrNull()) + enum class Value { + IN_ADVANCE, + IN_ARREAR, + /** + * An enum member indicating that [BillingMode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * Sets [Builder.discount] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.discount] with a well-typed [Discount] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun discount(discount: JsonField) = apply { this.discount = discount } - - /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ - @Deprecated("deprecated") - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - /** - * Alias for calling [discount] with the following: - * ```java - * PercentageDiscount.builder() - * .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - @Deprecated("deprecated") - fun percentageDiscount(percentageDiscount: Double) = - discount( - PercentageDiscount.builder() - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(percentageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofTrial(trial)`. */ - @Deprecated("deprecated") - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - /** Alias for calling [discount] with `Discount.ofUsage(usage)`. */ - @Deprecated("deprecated") - fun discount(usage: UsageDiscount) = discount(Discount.ofUsage(usage)) + fun value(): Value = + when (this) { + IN_ADVANCE -> Value.IN_ADVANCE + IN_ARREAR -> Value.IN_ARREAR + else -> Value._UNKNOWN + } /** - * Alias for calling [discount] with the following: - * ```java - * UsageDiscount.builder() - * .discountType(UsageDiscount.DiscountType.USAGE) - * .usageDiscount(usageDiscount) - * .build() - * ``` + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. */ - @Deprecated("deprecated") - fun usageDiscount(usageDiscount: Double) = - discount( - UsageDiscount.builder() - .discountType(UsageDiscount.DiscountType.USAGE) - .usageDiscount(usageDiscount) - .build() - ) - - /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ - @Deprecated("deprecated") - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + fun known(): Known = + when (this) { + IN_ADVANCE -> Known.IN_ADVANCE + IN_ARREAR -> Known.IN_ARREAR + else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + } /** - * Alias for calling [discount] with the following: - * ```java - * AmountDiscount.builder() - * .discountType(AmountDiscount.DiscountType.AMOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - @Deprecated("deprecated") - fun amountDiscount(amountDiscount: String) = - discount( - AmountDiscount.builder() - .discountType(AmountDiscount.DiscountType.AMOUNT) - .amountDiscount(amountDiscount) - .build() - ) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + private var validated: Boolean = false /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + fun validate(): BillingMode = apply { + if (validated) { + return@apply + } + + known() + validated = true } - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Alias for [Builder.fixedPriceQuantity]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + return other is BillingMode && value == other.value } - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: BillingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + override fun hashCode() = value.hashCode() - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + override fun toString() = value.toString() + } + + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * Returns this class instance's raw value. * - * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed - * [BillingCycleConfiguration] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * A minimal representation of an Item containing only the essential identifying - * information. - */ - fun item(item: ItemSlim) = item(JsonField.of(item)) + companion object { - /** - * Sets [Builder.item] to an arbitrary JSON value. - * - * You should usually call [Builder.item] with a well-typed [ItemSlim] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun item(item: JsonField) = apply { this.item = item } + @JvmField val ONE_TIME = of("one_time") - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + @JvmField val MONTHLY = of("monthly") - /** Alias for calling [Builder.maximum] with `maximum.orElse(null)`. */ - @Deprecated("deprecated") - fun maximum(maximum: Optional) = maximum(maximum.getOrNull()) + @JvmField val QUARTERLY = of("quarterly") - /** - * Sets [Builder.maximum] to an arbitrary JSON value. - * - * You should usually call [Builder.maximum] with a well-typed [Maximum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + @JvmField val SEMI_ANNUAL = of("semi_annual") - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + @JvmField val ANNUAL = of("annual") - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) + @JvmField val CUSTOM = of("custom") - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and - * the entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } /** - * Sets [Builder.metadata] to an arbitrary JSON value. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - /** Alias for calling [Builder.minimum] with `minimum.orElse(null)`. */ - @Deprecated("deprecated") - fun minimum(minimum: Optional) = minimum(minimum.getOrNull()) + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } /** - * Sets [Builder.minimum] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * You should usually call [Builder.minimum] with a well-typed [Minimum] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.getOrNull()) + fun value(): Value = + when (this) { + ONE_TIME -> Value.ONE_TIME + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * Returns an enum member corresponding to this class instance's value. * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + fun known(): Known = + when (this) { + ONE_TIME -> Known.ONE_TIME + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } /** - * Sets the field to an arbitrary JSON value. + * Returns this class instance's primitive wire representation. * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("scalable_matrix_with_unit_pricing") - * ``` + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - fun name(name: String) = name(JsonField.of(name)) + private var validated: Boolean = false /** - * Sets [Builder.name] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected types + * recursively. * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun name(name: JsonField) = apply { this.name = name } + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Alias for [Builder.planPhaseOrder]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This unboxed primitive overload exists for backwards compatibility. + * Used for best match union deserialization. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** Alias for calling [Builder.planPhaseOrder] with `planPhaseOrder.orElse(null)`. */ - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.getOrNull()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.planPhaseOrder] to an arbitrary JSON value. - * - * You should usually call [Builder.planPhaseOrder] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder + return other is Cadence && value == other.value } - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CompositePriceFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val operator: JsonField, + private val values: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("values") + @ExcludeMissing + values: JsonField> = JsonMissing.of(), + ) : this(field, operator, values, mutableMapOf()) /** - * Sets [Builder.priceType] to an arbitrary JSON value. + * The property of the price to filter on. * - * You should usually call [Builder.priceType] with a well-typed [PriceType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + fun field(): Field = field.getRequired("field") /** - * The price id this price replaces. This price will take the place of the replaced - * price in plan version migrations. + * Should prices that match the filter be included or excluded. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun replacesPriceId(replacesPriceId: String?) = - replacesPriceId(JsonField.ofNullable(replacesPriceId)) - - /** Alias for calling [Builder.replacesPriceId] with `replacesPriceId.orElse(null)`. */ - fun replacesPriceId(replacesPriceId: Optional) = - replacesPriceId(replacesPriceId.getOrNull()) + fun operator(): Operator = operator.getRequired("operator") /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * The IDs or values that match this filter. * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } - - /** Configuration for scalable_matrix_with_unit_pricing pricing */ - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = - scalableMatrixWithUnitPricingConfig( - JsonField.of(scalableMatrixWithUnitPricingConfig) - ) + fun values(): List = values.getRequired("values") /** - * Sets [Builder.scalableMatrixWithUnitPricingConfig] to an arbitrary JSON value. + * Returns the raw JSON value of [field]. * - * You should usually call [Builder.scalableMatrixWithUnitPricingConfig] with a - * well-typed [ScalableMatrixWithUnitPricingConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported value. + * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. */ - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: JsonField - ) = apply { - this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig - } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * Returns the raw JSON value of [values]. * - * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed - * [DimensionalPriceConfiguration] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values - fun putAdditionalProperty(key: String, value: JsonValue) = apply { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** A builder for [CompositePriceFilter]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + private var field: JsonField? = null + private var operator: JsonField? = null + private var values: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(compositePriceFilter: CompositePriceFilter) = apply { + field = compositePriceFilter.field + operator = compositePriceFilter.operator + values = compositePriceFilter.values.map { it.toMutableList() } + additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() + } + + /** The property of the price to filter on. */ + fun field(field: Field) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [Field] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** Should prices that match the filter be included or excluded. */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The IDs or values that match this filter. */ + fun values(values: List) = values(JsonField.of(values)) + + /** + * Sets [Builder.values] to an arbitrary JSON value. + * + * You should usually call [Builder.values] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun values(values: JsonField>) = apply { + this.values = values.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [values]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: String) = apply { + values = + (values ?: JsonField.of(mutableListOf())).also { + checkKnown("values", it).add(value) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompositePriceFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .operator() + * .values() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompositePriceFilter = + CompositePriceFilter( + checkRequired("field", field), + checkRequired("operator", operator), + checkRequired("values", values).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } + private var validated: Boolean = false + /** - * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * Validates that the types of all values in this object match their expected types + * recursively. * - * The following fields are required: - * ```java - * .id() - * .billableMetric() - * .billingCycleConfiguration() - * .billingMode() - * .cadence() - * .compositePriceFilters() - * .conversionRate() - * .conversionRateConfig() - * .createdAt() - * .creditAllocation() - * .currency() - * .discount() - * .externalPriceId() - * .fixedPriceQuantity() - * .invoicingCycleConfiguration() - * .item() - * .maximum() - * .maximumAmount() - * .metadata() - * .minimum() - * .minimumAmount() - * .name() - * .planPhaseOrder() - * .priceType() - * .replacesPriceId() - * .scalableMatrixWithUnitPricingConfig() - * ``` + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws IllegalStateException if any required field is unset. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - fun build(): ScalableMatrixWithUnitPricing = - ScalableMatrixWithUnitPricing( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("billingMode", billingMode), - checkRequired("cadence", cadence), - checkRequired("compositePriceFilters", compositePriceFilters).map { - it.toImmutable() - }, - checkRequired("conversionRate", conversionRate), - checkRequired("conversionRateConfig", conversionRateConfig), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - modelType, - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("replacesPriceId", replacesPriceId), - checkRequired( - "scalableMatrixWithUnitPricingConfig", - scalableMatrixWithUnitPricingConfig, - ), - dimensionalPriceConfiguration, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithUnitPricing = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - billingMode().validate() - cadence().validate() - compositePriceFilters().ifPresent { it.forEach { it.validate() } } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - createdAt() - creditAllocation().ifPresent { it.validate() } - currency() - discount().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoicingCycleConfiguration().ifPresent { it.validate() } - item().validate() - maximum().ifPresent { it.validate() } - maximumAmount() - metadata().validate() - minimum().ifPresent { it.validate() } - minimumAmount() - _modelType().let { - if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") + fun validate(): CompositePriceFilter = apply { + if (validated) { + return@apply } - } - name() - planPhaseOrder() - priceType().validate() - replacesPriceId() - scalableMatrixWithUnitPricingConfig().validate() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + field().validate() + operator().validate() + values() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (billableMetric.asKnown().getOrNull()?.validity() ?: 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (billingMode.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (compositePriceFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (discount.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (item.asKnown().getOrNull()?.validity() ?: 0) + - (maximum.asKnown().getOrNull()?.validity() ?: 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (minimum.asKnown().getOrNull()?.validity() ?: 0) + - (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 - } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + - (priceType.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) - - class BillingMode @JsonCreator private constructor(private val value: JsonField) : - Enum { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns this class instance's raw value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * Used for best match union deserialization. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JvmSynthetic + internal fun validity(): Int = + (field.asKnown().getOrNull()?.validity() ?: 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (values.asKnown().getOrNull()?.size ?: 0) - companion object { + /** The property of the price to filter on. */ + class Field @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmField val IN_ADVANCE = of("in_advance") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JvmField val IN_ARREAR = of("in_arrear") + companion object { + + @JvmField val PRICE_ID = of("price_id") + + @JvmField val ITEM_ID = of("item_id") + + @JvmField val PRICE_TYPE = of("price_type") + + @JvmField val CURRENCY = of("currency") + + @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + /** An enum containing [Field]'s known values. */ + enum class Known { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + } + + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PRICE_ID, + ITEM_ID, + PRICE_TYPE, + CURRENCY, + PRICING_UNIT_ID, + /** + * An enum member indicating that [Field] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PRICE_ID -> Value.PRICE_ID + ITEM_ID -> Value.ITEM_ID + PRICE_TYPE -> Value.PRICE_TYPE + CURRENCY -> Value.CURRENCY + PRICING_UNIT_ID -> Value.PRICING_UNIT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PRICE_ID -> Known.PRICE_ID + ITEM_ID -> Known.ITEM_ID + PRICE_TYPE -> Known.PRICE_TYPE + CURRENCY -> Known.CURRENCY + PRICING_UNIT_ID -> Known.PRICING_UNIT_ID + else -> throw OrbInvalidDataException("Unknown Field: $value") + } - @JvmStatic fun of(value: String) = BillingMode(JsonField.of(value)) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** An enum containing [BillingMode]'s known values. */ - enum class Known { - IN_ADVANCE, - IN_ARREAR, - } + private var validated: Boolean = false - /** - * An enum containing [BillingMode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [BillingMode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - IN_ADVANCE, - IN_ARREAR, /** - * An enum member indicating that [BillingMode] was instantiated with an unknown - * value. + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - IN_ADVANCE -> Value.IN_ADVANCE - IN_ARREAR -> Value.IN_ARREAR - else -> Value._UNKNOWN - } + fun validate(): Field = apply { + if (validated) { + return@apply + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - IN_ADVANCE -> Known.IN_ADVANCE - IN_ARREAR -> Known.IN_ARREAR - else -> throw OrbInvalidDataException("Unknown BillingMode: $value") + known() + validated = true } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun validate(): BillingMode = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + return other is Field && value == other.value } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun hashCode() = value.hashCode() - return other is BillingMode && value == other.value + override fun toString() = value.toString() } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** Should prices that match the filter be included or excluded. */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { - class Cadence @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + companion object { - companion object { + @JvmField val INCLUDES = of("includes") - @JvmField val ONE_TIME = of("one_time") + @JvmField val EXCLUDES = of("excludes") - @JvmField val MONTHLY = of("monthly") + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } - @JvmField val QUARTERLY = of("quarterly") + /** An enum containing [Operator]'s known values. */ + enum class Known { + INCLUDES, + EXCLUDES, + } - @JvmField val SEMI_ANNUAL = of("semi_annual") + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCLUDES, + EXCLUDES, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - @JvmField val ANNUAL = of("annual") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCLUDES -> Value.INCLUDES + EXCLUDES -> Value.EXCLUDES + else -> Value._UNKNOWN + } - @JvmField val CUSTOM = of("custom") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCLUDES -> Known.INCLUDES + EXCLUDES -> Known.EXCLUDES + else -> throw OrbInvalidDataException("Unknown Operator: $value") + } - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, - } + private var validated: Boolean = false - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ONE_TIME, - MONTHLY, - QUARTERLY, - SEMI_ANNUAL, - ANNUAL, - CUSTOM, /** - * An enum member indicating that [Cadence] was instantiated with an unknown value. + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - _UNKNOWN, - } + fun validate(): Operator = apply { + if (validated) { + return@apply + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN + known() + validated = true } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Cadence = apply { - if (validated) { - return@apply + return other is Operator && value == other.value } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Cadence && value == other.value + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - class CompositePriceFilter + /** Configuration for cumulative_grouped_bulk pricing */ + class CumulativeGroupedBulkConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val field: JsonField, - private val operator: JsonField, - private val values: JsonField>, + private val dimensionValues: JsonField>, + private val group: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("values") + @JsonProperty("dimension_values") @ExcludeMissing - values: JsonField> = JsonMissing.of(), - ) : this(field, operator, values, mutableMapOf()) - - /** - * The property of the price to filter on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun field(): Field = field.getRequired("field") + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), + ) : this(dimensionValues, group, mutableMapOf()) /** - * Should prices that match the filter be included or excluded. + * Each tier lower bound must have the same group of values. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun operator(): Operator = operator.getRequired("operator") + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") /** - * The IDs or values that match this filter. - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun values(): List = values.getRequired("values") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + fun group(): String = group.getRequired("group") /** - * Returns the raw JSON value of [operator]. + * Returns the raw JSON value of [dimensionValues]. * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("operator") + @JsonProperty("dimension_values") @ExcludeMissing - fun _operator(): JsonField = operator + fun _dimensionValues(): JsonField> = dimensionValues /** - * Returns the raw JSON value of [values]. + * Returns the raw JSON value of [group]. * - * Unlike [values], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("values") @ExcludeMissing fun _values(): JsonField> = values + @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -74789,84 +98909,73 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CompositePriceFilter]. + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulkConfig]. * * The following fields are required: * ```java - * .field() - * .operator() - * .values() + * .dimensionValues() + * .group() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CompositePriceFilter]. */ + /** A builder for [CumulativeGroupedBulkConfig]. */ class Builder internal constructor() { - private var field: JsonField? = null - private var operator: JsonField? = null - private var values: JsonField>? = null + private var dimensionValues: JsonField>? = null + private var group: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(compositePriceFilter: CompositePriceFilter) = apply { - field = compositePriceFilter.field - operator = compositePriceFilter.operator - values = compositePriceFilter.values.map { it.toMutableList() } - additionalProperties = compositePriceFilter.additionalProperties.toMutableMap() - } - - /** The property of the price to filter on. */ - fun field(field: Field) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed [Field] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** Should prices that match the filter be included or excluded. */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } + internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = + apply { + dimensionValues = + cumulativeGroupedBulkConfig.dimensionValues.map { it.toMutableList() } + group = cumulativeGroupedBulkConfig.group + additionalProperties = + cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() + } - /** The IDs or values that match this filter. */ - fun values(values: List) = values(JsonField.of(values)) + /** Each tier lower bound must have the same group of values. */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) /** - * Sets [Builder.values] to an arbitrary JSON value. + * Sets [Builder.dimensionValues] to an arbitrary JSON value. * - * You should usually call [Builder.values] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun values(values: JsonField>) = apply { - this.values = values.map { it.toMutableList() } + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** - * Adds a single [String] to [values]. + * Adds a single [DimensionValue] to [dimensionValues]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addValue(value: String) = apply { - values = - (values ?: JsonField.of(mutableListOf())).also { - checkKnown("values", it).add(value) + fun addDimensionValue(dimensionValue: DimensionValue) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) } } + fun group(group: String) = group(JsonField.of(group)) + + /** + * Sets [Builder.group] to an arbitrary JSON value. + * + * You should usually call [Builder.group] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun group(group: JsonField) = apply { this.group = group } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -74890,38 +98999,45 @@ private constructor( } /** - * Returns an immutable instance of [CompositePriceFilter]. + * Returns an immutable instance of [CumulativeGroupedBulkConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .field() - * .operator() - * .values() + * .dimensionValues() + * .group() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CompositePriceFilter = - CompositePriceFilter( - checkRequired("field", field), - checkRequired("operator", operator), - checkRequired("values", values).map { it.toImmutable() }, + fun build(): CumulativeGroupedBulkConfig = + CumulativeGroupedBulkConfig( + checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, + checkRequired("group", group), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CompositePriceFilter = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CumulativeGroupedBulkConfig = apply { if (validated) { return@apply } - field().validate() - operator().validate() - values() + dimensionValues().forEach { it.validate() } + group() validated = true } @@ -74941,260 +99057,240 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (field.asKnown().getOrNull()?.validity() ?: 0) + - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (values.asKnown().getOrNull()?.size ?: 0) + (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (group.asKnown().isPresent) 1 else 0) - /** The property of the price to filter on. */ - class Field @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** Configuration for a dimension value entry */ + class DimensionValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) /** - * Returns this class instance's raw value. + * Grouping key value * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PRICE_ID = of("price_id") - - @JvmField val ITEM_ID = of("item_id") - - @JvmField val PRICE_TYPE = of("price_type") - - @JvmField val CURRENCY = of("currency") - - @JvmField val PRICING_UNIT_ID = of("pricing_unit_id") - - @JvmStatic fun of(value: String) = Field(JsonField.of(value)) - } - - /** An enum containing [Field]'s known values. */ - enum class Known { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - } + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * Tier lower bound * - * An instance of [Field] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - enum class Value { - PRICE_ID, - ITEM_ID, - PRICE_TYPE, - CURRENCY, - PRICING_UNIT_ID, - /** - * An enum member indicating that [Field] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Unit amount for this combination * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun value(): Value = - when (this) { - PRICE_ID -> Value.PRICE_ID - ITEM_ID -> Value.ITEM_ID - PRICE_TYPE -> Value.PRICE_TYPE - CURRENCY -> Value.CURRENCY - PRICING_UNIT_ID -> Value.PRICING_UNIT_ID - else -> Value._UNKNOWN - } + fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * Returns the raw JSON value of [groupingKey]. * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun known(): Known = - when (this) { - PRICE_ID -> Known.PRICE_ID - ITEM_ID -> Known.ITEM_ID - PRICE_TYPE -> Known.PRICE_TYPE - CURRENCY -> Known.CURRENCY - PRICING_UNIT_ID -> Known.PRICING_UNIT_ID - else -> throw OrbInvalidDataException("Unknown Field: $value") - } + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey /** - * Returns this class instance's primitive wire representation. + * Returns the raw JSON value of [tierLowerBound]. * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun validate(): Field = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - known() - validated = true + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DimensionValue]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** A builder for [DimensionValue]. */ + class Builder internal constructor() { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private var groupingKey: JsonField? = null + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JvmSynthetic + internal fun from(dimensionValue: DimensionValue) = apply { + groupingKey = dimensionValue.groupingKey + tierLowerBound = dimensionValue.tierLowerBound + unitAmount = dimensionValue.unitAmount + additionalProperties = dimensionValue.additionalProperties.toMutableMap() } - return other is Field && value == other.value - } + /** Grouping key value */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) - override fun hashCode() = value.hashCode() + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - override fun toString() = value.toString() - } + /** Tier lower bound */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - /** Should prices that match the filter be included or excluded. */ - class Operator @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** Unit amount for this combination */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - companion object { + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - @JvmField val INCLUDES = of("includes") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmField val EXCLUDES = of("excludes") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** An enum containing [Operator]'s known values. */ - enum class Known { - INCLUDES, - EXCLUDES, - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCLUDES, - EXCLUDES, /** - * An enum member indicating that [Operator] was instantiated with an unknown - * value. + * Returns an immutable instance of [DimensionValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - _UNKNOWN, + fun build(): DimensionValue = + DimensionValue( + checkRequired("groupingKey", groupingKey), + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCLUDES -> Value.INCLUDES - EXCLUDES -> Value.EXCLUDES - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCLUDES -> Known.INCLUDES - EXCLUDES -> Known.EXCLUDES - else -> throw OrbInvalidDataException("Unknown Operator: $value") - } + private var validated: Boolean = false /** - * Returns this class instance's primitive wire representation. + * Validates that the types of all values in this object match their expected types + * recursively. * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { + fun validate(): DimensionValue = apply { if (validated) { return@apply } - known() + groupingKey() + tierLowerBound() + unitAmount() validated = true } @@ -75212,19 +99308,32 @@ 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 = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Operator && value == other.value + return other is DimensionValue && + groupingKey == other.groupingKey && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(groupingKey, tierLowerBound, unitAmount, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -75232,21 +99341,20 @@ private constructor( return true } - return other is CompositePriceFilter && - field == other.field && - operator == other.operator && - values == other.values && + return other is CumulativeGroupedBulkConfig && + dimensionValues == other.dimensionValues && + group == other.group && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(field, operator, values, additionalProperties) + Objects.hash(dimensionValues, group, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" } /** @@ -75315,6 +99423,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -75453,6 +99571,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -75491,135 +99619,79 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for scalable_matrix_with_unit_pricing pricing */ - class ScalableMatrixWithUnitPricingConfig + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val firstDimension: JsonField, - private val matrixScalingFactors: JsonField>, - private val unitPrice: JsonField, - private val prorate: JsonField, - private val secondDimension: JsonField, + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("first_dimension") - @ExcludeMissing - firstDimension: JsonField = JsonMissing.of(), - @JsonProperty("matrix_scaling_factors") - @ExcludeMissing - matrixScalingFactors: JsonField> = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - @JsonProperty("prorate") - @ExcludeMissing - prorate: JsonField = JsonMissing.of(), - @JsonProperty("second_dimension") + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") @ExcludeMissing - secondDimension: JsonField = JsonMissing.of(), - ) : this( - firstDimension, - matrixScalingFactors, - unitPrice, - prorate, - secondDimension, - mutableMapOf(), - ) - - /** - * Used to determine the unit rate - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun firstDimension(): String = firstDimension.getRequired("first_dimension") + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) /** - * Apply a scaling factor to each dimension + * The Orb-assigned unique identifier for the license type. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun matrixScalingFactors(): List = - matrixScalingFactors.getRequired("matrix_scaling_factors") + fun id(): String = id.getRequired("id") /** - * The final unit price to rate against the output of the matrix + * The key used for grouping licenses of this type. This is typically a user identifier + * field. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun unitPrice(): String = unitPrice.getRequired("unit_price") - - /** - * If true, the unit price will be prorated to the billing period - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun prorate(): Optional = prorate.getOptional("prorate") - - /** - * Used to determine the unit rate (optional) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun secondDimension(): Optional = - secondDimension.getOptional("second_dimension") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * Returns the raw JSON value of [firstDimension]. + * The name of the license type. * - * Unlike [firstDimension], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - @JsonProperty("first_dimension") - @ExcludeMissing - fun _firstDimension(): JsonField = firstDimension + fun name(): String = name.getRequired("name") /** - * Returns the raw JSON value of [matrixScalingFactors]. + * Returns the raw JSON value of [id]. * - * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("matrix_scaling_factors") - @ExcludeMissing - fun _matrixScalingFactors(): JsonField> = matrixScalingFactors + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [unitPrice]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("unit_price") + @JsonProperty("grouping_key") @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice - - /** - * Returns the raw JSON value of [prorate]. - * - * Unlike [prorate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("prorate") @ExcludeMissing fun _prorate(): JsonField = prorate + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [secondDimension]. + * Returns the raw JSON value of [name]. * - * Unlike [secondDimension], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("second_dimension") - @ExcludeMissing - fun _secondDimension(): JsonField = secondDimension + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -75636,144 +99708,74 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithUnitPricingConfig]. + * Returns a mutable builder for constructing an instance of [LicenseType]. * * The following fields are required: * ```java - * .firstDimension() - * .matrixScalingFactors() - * .unitPrice() + * .id() + * .groupingKey() + * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ + /** A builder for [LicenseType]. */ class Builder internal constructor() { - private var firstDimension: JsonField? = null - private var matrixScalingFactors: JsonField>? = - null - private var unitPrice: JsonField? = null - private var prorate: JsonField = JsonMissing.of() - private var secondDimension: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = apply { - firstDimension = scalableMatrixWithUnitPricingConfig.firstDimension - matrixScalingFactors = - scalableMatrixWithUnitPricingConfig.matrixScalingFactors.map { - it.toMutableList() - } - unitPrice = scalableMatrixWithUnitPricingConfig.unitPrice - prorate = scalableMatrixWithUnitPricingConfig.prorate - secondDimension = scalableMatrixWithUnitPricingConfig.secondDimension - additionalProperties = - scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() - } - - /** Used to determine the unit rate */ - fun firstDimension(firstDimension: String) = - firstDimension(JsonField.of(firstDimension)) - - /** - * Sets [Builder.firstDimension] to an arbitrary JSON value. - * - * You should usually call [Builder.firstDimension] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun firstDimension(firstDimension: JsonField) = apply { - this.firstDimension = firstDimension - } - - /** Apply a scaling factor to each dimension */ - fun matrixScalingFactors(matrixScalingFactors: List) = - matrixScalingFactors(JsonField.of(matrixScalingFactors)) - - /** - * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. - * - * You should usually call [Builder.matrixScalingFactors] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun matrixScalingFactors( - matrixScalingFactors: JsonField> - ) = apply { - this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } - } - - /** - * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { - matrixScalingFactors = - (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { - checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) - } + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() } - /** The final unit price to rate against the output of the matrix */ - fun unitPrice(unitPrice: String) = unitPrice(JsonField.of(unitPrice)) + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.unitPrice] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } - - /** If true, the unit price will be prorated to the billing period */ - fun prorate(prorate: Boolean?) = prorate(JsonField.ofNullable(prorate)) + fun id(id: JsonField) = apply { this.id = id } /** - * Alias for [Builder.prorate]. - * - * This unboxed primitive overload exists for backwards compatibility. + * The key used for grouping licenses of this type. This is typically a user + * identifier field. */ - fun prorate(prorate: Boolean) = prorate(prorate as Boolean?) - - /** Alias for calling [Builder.prorate] with `prorate.orElse(null)`. */ - fun prorate(prorate: Optional) = prorate(prorate.getOrNull()) + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.prorate] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.prorate] with a well-typed [Boolean] value + * You should usually call [Builder.groupingKey] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun prorate(prorate: JsonField) = apply { this.prorate = prorate } - - /** Used to determine the unit rate (optional) */ - fun secondDimension(secondDimension: String?) = - secondDimension(JsonField.ofNullable(secondDimension)) + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. - */ - fun secondDimension(secondDimension: Optional) = - secondDimension(secondDimension.getOrNull()) + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) /** - * Sets [Builder.secondDimension] to an arbitrary JSON value. + * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.secondDimension] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun secondDimension(secondDimension: JsonField) = apply { - this.secondDimension = secondDimension - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -75798,44 +99800,48 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithUnitPricingConfig]. + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .firstDimension() - * .matrixScalingFactors() - * .unitPrice() + * .id() + * .groupingKey() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig( - checkRequired("firstDimension", firstDimension), - checkRequired("matrixScalingFactors", matrixScalingFactors).map { - it.toImmutable() - }, - checkRequired("unitPrice", unitPrice), - prorate, - secondDimension, + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ScalableMatrixWithUnitPricingConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { if (validated) { return@apply } - firstDimension() - matrixScalingFactors().forEach { it.validate() } - unitPrice() - prorate() - secondDimension() + id() + groupingKey() + name() validated = true } @@ -75855,314 +99861,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (firstDimension.asKnown().isPresent) 1 else 0) + - (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + - (if (prorate.asKnown().isPresent) 1 else 0) + - (if (secondDimension.asKnown().isPresent) 1 else 0) - - /** Configuration for a single matrix scaling factor */ - class MatrixScalingFactor - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val firstDimensionValue: JsonField, - private val scalingFactor: JsonField, - private val secondDimensionValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("first_dimension_value") - @ExcludeMissing - firstDimensionValue: JsonField = JsonMissing.of(), - @JsonProperty("scaling_factor") - @ExcludeMissing - scalingFactor: JsonField = JsonMissing.of(), - @JsonProperty("second_dimension_value") - @ExcludeMissing - secondDimensionValue: JsonField = JsonMissing.of(), - ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun firstDimensionValue(): String = - firstDimensionValue.getRequired("first_dimension_value") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun secondDimensionValue(): Optional = - secondDimensionValue.getOptional("second_dimension_value") - - /** - * Returns the raw JSON value of [firstDimensionValue]. - * - * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("first_dimension_value") - @ExcludeMissing - fun _firstDimensionValue(): JsonField = firstDimensionValue - - /** - * Returns the raw JSON value of [scalingFactor]. - * - * Unlike [scalingFactor], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("scaling_factor") - @ExcludeMissing - fun _scalingFactor(): JsonField = scalingFactor - - /** - * Returns the raw JSON value of [secondDimensionValue]. - * - * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("second_dimension_value") - @ExcludeMissing - fun _secondDimensionValue(): JsonField = secondDimensionValue - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [MatrixScalingFactor]. - * - * The following fields are required: - * ```java - * .firstDimensionValue() - * .scalingFactor() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixScalingFactor]. */ - class Builder internal constructor() { - - private var firstDimensionValue: JsonField? = null - private var scalingFactor: JsonField? = null - private var secondDimensionValue: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { - firstDimensionValue = matrixScalingFactor.firstDimensionValue - scalingFactor = matrixScalingFactor.scalingFactor - secondDimensionValue = matrixScalingFactor.secondDimensionValue - additionalProperties = - matrixScalingFactor.additionalProperties.toMutableMap() - } - - fun firstDimensionValue(firstDimensionValue: String) = - firstDimensionValue(JsonField.of(firstDimensionValue)) - - /** - * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. - * - * You should usually call [Builder.firstDimensionValue] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun firstDimensionValue(firstDimensionValue: JsonField) = apply { - this.firstDimensionValue = firstDimensionValue - } - - fun scalingFactor(scalingFactor: String) = - scalingFactor(JsonField.of(scalingFactor)) - - /** - * Sets [Builder.scalingFactor] to an arbitrary JSON value. - * - * You should usually call [Builder.scalingFactor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun scalingFactor(scalingFactor: JsonField) = apply { - this.scalingFactor = scalingFactor - } - - fun secondDimensionValue(secondDimensionValue: String?) = - secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) - - /** - * Alias for calling [Builder.secondDimensionValue] with - * `secondDimensionValue.orElse(null)`. - */ - fun secondDimensionValue(secondDimensionValue: Optional) = - secondDimensionValue(secondDimensionValue.getOrNull()) - - /** - * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. - * - * You should usually call [Builder.secondDimensionValue] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun secondDimensionValue(secondDimensionValue: JsonField) = apply { - this.secondDimensionValue = secondDimensionValue - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MatrixScalingFactor]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .firstDimensionValue() - * .scalingFactor() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MatrixScalingFactor = - MatrixScalingFactor( - checkRequired("firstDimensionValue", firstDimensionValue), - checkRequired("scalingFactor", scalingFactor), - secondDimensionValue, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MatrixScalingFactor = apply { - if (validated) { - return@apply - } - - firstDimensionValue() - scalingFactor() - secondDimensionValue() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + - (if (scalingFactor.asKnown().isPresent) 1 else 0) + - (if (secondDimensionValue.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MatrixScalingFactor && - firstDimensionValue == other.firstDimensionValue && - scalingFactor == other.scalingFactor && - secondDimensionValue == other.secondDimensionValue && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - firstDimensionValue, - scalingFactor, - secondDimensionValue, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" - } + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ScalableMatrixWithUnitPricingConfig && - firstDimension == other.firstDimension && - matrixScalingFactors == other.matrixScalingFactors && - unitPrice == other.unitPrice && - prorate == other.prorate && - secondDimension == other.secondDimension && + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - firstDimension, - matrixScalingFactors, - unitPrice, - prorate, - secondDimension, - additionalProperties, - ) + Objects.hash(id, groupingKey, name, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, unitPrice=$unitPrice, prorate=$prorate, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -76170,7 +99892,7 @@ private constructor( return true } - return other is ScalableMatrixWithUnitPricing && + return other is CumulativeGroupedBulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -76181,10 +99903,12 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && + cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -76197,8 +99921,8 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -76214,10 +99938,12 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedBulkConfig, currency, discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -76230,8 +99956,8 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -76239,10 +99965,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class ScalableMatrixWithTieredPricing + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -76255,10 +99981,12 @@ private constructor( private val conversionRateConfig: JsonField, private val createdAt: JsonField, private val creditAllocation: JsonField, + private val cumulativeGroupedAllocationConfig: JsonField, private val currency: JsonField, private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -76271,9 +99999,8 @@ private constructor( private val planPhaseOrder: JsonField, private val priceType: JsonField, private val replacesPriceId: JsonField, - private val scalableMatrixWithTieredPricingConfig: - JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -76305,6 +100032,10 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: JsonField = + JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -76317,6 +100048,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -76343,15 +100077,13 @@ private constructor( @JsonProperty("replaces_price_id") @ExcludeMissing replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - scalableMatrixWithTieredPricingConfig: - JsonField = - JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -76363,10 +100095,12 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedAllocationConfig, currency, discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -76379,8 +100113,8 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -76449,6 +100183,15 @@ private constructor( fun creditAllocation(): Optional = creditAllocation.getOptional("credit_allocation") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired("cumulative_grouped_allocation_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -76475,6 +100218,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -76532,7 +100282,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("scalable_matrix_with_tiered_pricing") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -76568,22 +100318,20 @@ private constructor( fun replacesPriceId(): Optional = replacesPriceId.getOptional("replaces_price_id") /** - * Configuration for scalable_matrix_with_tiered_pricing pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingConfig.getRequired( - "scalable_matrix_with_tiered_pricing_config" - ) + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + fun licenseType(): Optional = licenseType.getOptional("license_type") /** * Returns the raw JSON value of [id]. @@ -76678,6 +100426,17 @@ private constructor( @ExcludeMissing fun _creditAllocation(): JsonField = creditAllocation + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): JsonField = + cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [currency]. * @@ -76715,6 +100474,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -76818,17 +100587,6 @@ private constructor( @ExcludeMissing fun _replacesPriceId(): JsonField = replacesPriceId - /** - * Returns the raw JSON value of [scalableMatrixWithTieredPricingConfig]. - * - * Unlike [scalableMatrixWithTieredPricingConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithTieredPricingConfig(): - JsonField = scalableMatrixWithTieredPricingConfig - /** * Returns the raw JSON value of [dimensionalPriceConfiguration]. * @@ -76840,6 +100598,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -76856,7 +100623,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithTieredPricing]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```java @@ -76870,10 +100637,12 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() + * .cumulativeGroupedAllocationConfig() * .currency() * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -76885,13 +100654,12 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithTieredPricingConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [ScalableMatrixWithTieredPricing]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -76904,10 +100672,14 @@ private constructor( private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null private var creditAllocation: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var currency: JsonField? = null private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -76915,59 +100687,55 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_tiered_pricing") + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null - private var scalableMatrixWithTieredPricingConfig: - JsonField? = - null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing) = - apply { - id = scalableMatrixWithTieredPricing.id - billableMetric = scalableMatrixWithTieredPricing.billableMetric - billingCycleConfiguration = - scalableMatrixWithTieredPricing.billingCycleConfiguration - billingMode = scalableMatrixWithTieredPricing.billingMode - cadence = scalableMatrixWithTieredPricing.cadence - compositePriceFilters = - scalableMatrixWithTieredPricing.compositePriceFilters.map { - it.toMutableList() - } - conversionRate = scalableMatrixWithTieredPricing.conversionRate - conversionRateConfig = scalableMatrixWithTieredPricing.conversionRateConfig - createdAt = scalableMatrixWithTieredPricing.createdAt - creditAllocation = scalableMatrixWithTieredPricing.creditAllocation - currency = scalableMatrixWithTieredPricing.currency - discount = scalableMatrixWithTieredPricing.discount - externalPriceId = scalableMatrixWithTieredPricing.externalPriceId - fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity - invoicingCycleConfiguration = - scalableMatrixWithTieredPricing.invoicingCycleConfiguration - item = scalableMatrixWithTieredPricing.item - maximum = scalableMatrixWithTieredPricing.maximum - maximumAmount = scalableMatrixWithTieredPricing.maximumAmount - metadata = scalableMatrixWithTieredPricing.metadata - minimum = scalableMatrixWithTieredPricing.minimum - minimumAmount = scalableMatrixWithTieredPricing.minimumAmount - modelType = scalableMatrixWithTieredPricing.modelType - name = scalableMatrixWithTieredPricing.name - planPhaseOrder = scalableMatrixWithTieredPricing.planPhaseOrder - priceType = scalableMatrixWithTieredPricing.priceType - replacesPriceId = scalableMatrixWithTieredPricing.replacesPriceId - scalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig - dimensionalPriceConfiguration = - scalableMatrixWithTieredPricing.dimensionalPriceConfiguration - additionalProperties = - scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = apply { + id = cumulativeGroupedAllocation.id + billableMetric = cumulativeGroupedAllocation.billableMetric + billingCycleConfiguration = cumulativeGroupedAllocation.billingCycleConfiguration + billingMode = cumulativeGroupedAllocation.billingMode + cadence = cumulativeGroupedAllocation.cadence + compositePriceFilters = + cumulativeGroupedAllocation.compositePriceFilters.map { it.toMutableList() } + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + createdAt = cumulativeGroupedAllocation.createdAt + creditAllocation = cumulativeGroupedAllocation.creditAllocation + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + discount = cumulativeGroupedAllocation.discount + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + item = cumulativeGroupedAllocation.item + maximum = cumulativeGroupedAllocation.maximum + maximumAmount = cumulativeGroupedAllocation.maximumAmount + metadata = cumulativeGroupedAllocation.metadata + minimum = cumulativeGroupedAllocation.minimum + minimumAmount = cumulativeGroupedAllocation.minimumAmount + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + planPhaseOrder = cumulativeGroupedAllocation.planPhaseOrder + priceType = cumulativeGroupedAllocation.priceType + replacesPriceId = cumulativeGroupedAllocation.replacesPriceId + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + licenseType = cumulativeGroupedAllocation.licenseType + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -77198,6 +100966,22 @@ private constructor( this.creditAllocation = creditAllocation } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = cumulativeGroupedAllocationConfig(JsonField.of(cumulativeGroupedAllocationConfig)) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a well-typed + * [CumulativeGroupedAllocationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: JsonField + ) = apply { this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig } + fun currency(currency: String) = currency(JsonField.of(currency)) /** @@ -77344,6 +101128,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -77480,7 +101285,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("scalable_matrix_with_tiered_pricing") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -77557,28 +101362,6 @@ private constructor( this.replacesPriceId = replacesPriceId } - /** Configuration for scalable_matrix_with_tiered_pricing pricing */ - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = - scalableMatrixWithTieredPricingConfig( - JsonField.of(scalableMatrixWithTieredPricingConfig) - ) - - /** - * Sets [Builder.scalableMatrixWithTieredPricingConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.scalableMatrixWithTieredPricingConfig] with a - * well-typed [ScalableMatrixWithTieredPricingConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported value. - */ - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: - JsonField - ) = apply { - this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig - } - fun dimensionalPriceConfiguration( dimensionalPriceConfiguration: DimensionalPriceConfiguration? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) @@ -77602,6 +101385,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -77622,7 +101428,7 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -77638,10 +101444,12 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() + * .cumulativeGroupedAllocationConfig() * .currency() * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -77653,13 +101461,12 @@ private constructor( * .planPhaseOrder() * .priceType() * .replacesPriceId() - * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithTieredPricing = - ScalableMatrixWithTieredPricing( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -77672,10 +101479,15 @@ private constructor( checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), checkRequired("creditAllocation", creditAllocation), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("currency", currency), checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -77688,18 +101500,24 @@ private constructor( checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), - checkRequired( - "scalableMatrixWithTieredPricingConfig", - scalableMatrixWithTieredPricingConfig, - ), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): ScalableMatrixWithTieredPricing = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } @@ -77714,10 +101532,12 @@ private constructor( conversionRateConfig().ifPresent { it.validate() } createdAt() creditAllocation().ifPresent { it.validate() } + cumulativeGroupedAllocationConfig().validate() currency() discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -77726,7 +101546,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -77734,8 +101554,8 @@ private constructor( planPhaseOrder() priceType().validate() replacesPriceId() - scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -77766,10 +101586,12 @@ private constructor( (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -77778,14 +101600,14 @@ private constructor( (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -77878,6 +101700,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -78030,6 +101862,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -78279,6 +102121,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -78422,6 +102274,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -78554,6 +102416,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -78587,31 +102459,364 @@ private constructor( return other is Operator && value == other.value } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompositePriceFilter && + field == other.field && + operator == other.operator && + values == other.values && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, operator, values, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(cumulativeAllocation, groupAllocation, groupingKey, unitAmount, mutableMapOf()) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CompositePriceFilter && - field == other.field && - operator == other.operator && - values == other.values && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(field, operator, values, additionalProperties) + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -78680,6 +102885,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -78816,886 +103031,322 @@ private constructor( fun asString(): String = _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - private var validated: Boolean = false - - fun validate(): PriceType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PriceType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for scalable_matrix_with_tiered_pricing pricing */ - class ScalableMatrixWithTieredPricingConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val firstDimension: JsonField, - private val matrixScalingFactors: JsonField>, - private val tiers: JsonField>, - private val secondDimension: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("first_dimension") - @ExcludeMissing - firstDimension: JsonField = JsonMissing.of(), - @JsonProperty("matrix_scaling_factors") - @ExcludeMissing - matrixScalingFactors: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - @JsonProperty("second_dimension") - @ExcludeMissing - secondDimension: JsonField = JsonMissing.of(), - ) : this(firstDimension, matrixScalingFactors, tiers, secondDimension, mutableMapOf()) - - /** - * Used for the scalable matrix first dimension - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun firstDimension(): String = firstDimension.getRequired("first_dimension") - - /** - * Apply a scaling factor to each dimension - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun matrixScalingFactors(): List = - matrixScalingFactors.getRequired("matrix_scaling_factors") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Used for the scalable matrix second dimension (optional) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun secondDimension(): Optional = - secondDimension.getOptional("second_dimension") - - /** - * Returns the raw JSON value of [firstDimension]. - * - * Unlike [firstDimension], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("first_dimension") - @ExcludeMissing - fun _firstDimension(): JsonField = firstDimension - - /** - * Returns the raw JSON value of [matrixScalingFactors]. - * - * Unlike [matrixScalingFactors], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("matrix_scaling_factors") - @ExcludeMissing - fun _matrixScalingFactors(): JsonField> = matrixScalingFactors - - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - /** - * Returns the raw JSON value of [secondDimension]. - * - * Unlike [secondDimension], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("second_dimension") - @ExcludeMissing - fun _secondDimension(): JsonField = secondDimension - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithTieredPricingConfig]. - * - * The following fields are required: - * ```java - * .firstDimension() - * .matrixScalingFactors() - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ - class Builder internal constructor() { - - private var firstDimension: JsonField? = null - private var matrixScalingFactors: JsonField>? = - null - private var tiers: JsonField>? = null - private var secondDimension: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = apply { - firstDimension = scalableMatrixWithTieredPricingConfig.firstDimension - matrixScalingFactors = - scalableMatrixWithTieredPricingConfig.matrixScalingFactors.map { - it.toMutableList() - } - tiers = scalableMatrixWithTieredPricingConfig.tiers.map { it.toMutableList() } - secondDimension = scalableMatrixWithTieredPricingConfig.secondDimension - additionalProperties = - scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() - } - - /** Used for the scalable matrix first dimension */ - fun firstDimension(firstDimension: String) = - firstDimension(JsonField.of(firstDimension)) - - /** - * Sets [Builder.firstDimension] to an arbitrary JSON value. - * - * You should usually call [Builder.firstDimension] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun firstDimension(firstDimension: JsonField) = apply { - this.firstDimension = firstDimension - } - - /** Apply a scaling factor to each dimension */ - fun matrixScalingFactors(matrixScalingFactors: List) = - matrixScalingFactors(JsonField.of(matrixScalingFactors)) - - /** - * Sets [Builder.matrixScalingFactors] to an arbitrary JSON value. - * - * You should usually call [Builder.matrixScalingFactors] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun matrixScalingFactors( - matrixScalingFactors: JsonField> - ) = apply { - this.matrixScalingFactors = matrixScalingFactors.map { it.toMutableList() } - } - - /** - * Adds a single [MatrixScalingFactor] to [matrixScalingFactors]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addMatrixScalingFactor(matrixScalingFactor: MatrixScalingFactor) = apply { - matrixScalingFactors = - (matrixScalingFactors ?: JsonField.of(mutableListOf())).also { - checkKnown("matrixScalingFactors", it).add(matrixScalingFactor) - } - } - - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } - - /** Used for the scalable matrix second dimension (optional) */ - fun secondDimension(secondDimension: String?) = - secondDimension(JsonField.ofNullable(secondDimension)) - - /** - * Alias for calling [Builder.secondDimension] with `secondDimension.orElse(null)`. - */ - fun secondDimension(secondDimension: Optional) = - secondDimension(secondDimension.getOrNull()) - - /** - * Sets [Builder.secondDimension] to an arbitrary JSON value. - * - * You should usually call [Builder.secondDimension] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun secondDimension(secondDimension: JsonField) = apply { - this.secondDimension = secondDimension - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ScalableMatrixWithTieredPricingConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .firstDimension() - * .matrixScalingFactors() - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig( - checkRequired("firstDimension", firstDimension), - checkRequired("matrixScalingFactors", matrixScalingFactors).map { - it.toImmutable() - }, - checkRequired("tiers", tiers).map { it.toImmutable() }, - secondDimension, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithTieredPricingConfig = apply { - if (validated) { - return@apply - } - - firstDimension() - matrixScalingFactors().forEach { it.validate() } - tiers().forEach { it.validate() } - secondDimension() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (firstDimension.asKnown().isPresent) 1 else 0) + - (matrixScalingFactors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (secondDimension.asKnown().isPresent) 1 else 0) - - /** Configuration for a single matrix scaling factor */ - class MatrixScalingFactor - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val firstDimensionValue: JsonField, - private val scalingFactor: JsonField, - private val secondDimensionValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("first_dimension_value") - @ExcludeMissing - firstDimensionValue: JsonField = JsonMissing.of(), - @JsonProperty("scaling_factor") - @ExcludeMissing - scalingFactor: JsonField = JsonMissing.of(), - @JsonProperty("second_dimension_value") - @ExcludeMissing - secondDimensionValue: JsonField = JsonMissing.of(), - ) : this(firstDimensionValue, scalingFactor, secondDimensionValue, mutableMapOf()) - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun firstDimensionValue(): String = - firstDimensionValue.getRequired("first_dimension_value") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun scalingFactor(): String = scalingFactor.getRequired("scaling_factor") - - /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun secondDimensionValue(): Optional = - secondDimensionValue.getOptional("second_dimension_value") - - /** - * Returns the raw JSON value of [firstDimensionValue]. - * - * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("first_dimension_value") - @ExcludeMissing - fun _firstDimensionValue(): JsonField = firstDimensionValue - - /** - * Returns the raw JSON value of [scalingFactor]. - * - * Unlike [scalingFactor], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("scaling_factor") - @ExcludeMissing - fun _scalingFactor(): JsonField = scalingFactor - - /** - * Returns the raw JSON value of [secondDimensionValue]. - * - * Unlike [secondDimensionValue], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("second_dimension_value") - @ExcludeMissing - fun _secondDimensionValue(): JsonField = secondDimensionValue - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [MatrixScalingFactor]. - * - * The following fields are required: - * ```java - * .firstDimensionValue() - * .scalingFactor() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + private var validated: Boolean = false - /** A builder for [MatrixScalingFactor]. */ - class Builder internal constructor() { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply + } - private var firstDimensionValue: JsonField? = null - private var scalingFactor: JsonField? = null - private var secondDimensionValue: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + known() + validated = true + } - @JvmSynthetic - internal fun from(matrixScalingFactor: MatrixScalingFactor) = apply { - firstDimensionValue = matrixScalingFactor.firstDimensionValue - scalingFactor = matrixScalingFactor.scalingFactor - secondDimensionValue = matrixScalingFactor.secondDimensionValue - additionalProperties = - matrixScalingFactor.additionalProperties.toMutableMap() - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun firstDimensionValue(firstDimensionValue: String) = - firstDimensionValue(JsonField.of(firstDimensionValue)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. - * - * You should usually call [Builder.firstDimensionValue] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun firstDimensionValue(firstDimensionValue: JsonField) = apply { - this.firstDimensionValue = firstDimensionValue - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun scalingFactor(scalingFactor: String) = - scalingFactor(JsonField.of(scalingFactor)) + return other is PriceType && value == other.value + } - /** - * Sets [Builder.scalingFactor] to an arbitrary JSON value. - * - * You should usually call [Builder.scalingFactor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun scalingFactor(scalingFactor: JsonField) = apply { - this.scalingFactor = scalingFactor - } + override fun hashCode() = value.hashCode() - fun secondDimensionValue(secondDimensionValue: String?) = - secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + override fun toString() = value.toString() + } - /** - * Alias for calling [Builder.secondDimensionValue] with - * `secondDimensionValue.orElse(null)`. - */ - fun secondDimensionValue(secondDimensionValue: Optional) = - secondDimensionValue(secondDimensionValue.getOrNull()) + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. - * - * You should usually call [Builder.secondDimensionValue] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun secondDimensionValue(secondDimensionValue: JsonField) = apply { - this.secondDimensionValue = secondDimensionValue - } + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** - * Returns an immutable instance of [MatrixScalingFactor]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .firstDimensionValue() - * .scalingFactor() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MatrixScalingFactor = - MatrixScalingFactor( - checkRequired("firstDimensionValue", firstDimensionValue), - checkRequired("scalingFactor", scalingFactor), - secondDimensionValue, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun validate(): MatrixScalingFactor = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - firstDimensionValue() - scalingFactor() - secondDimensionValue() - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns a mutable builder for constructing an instance of [LicenseType]. * - * Used for best match union deserialization. + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` */ - @JvmSynthetic - internal fun validity(): Int = - (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + - (if (scalingFactor.asKnown().isPresent) 1 else 0) + - (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + @JvmStatic fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [LicenseType]. */ + class Builder internal constructor() { - return other is MatrixScalingFactor && - firstDimensionValue == other.firstDimensionValue && - scalingFactor == other.scalingFactor && - secondDimensionValue == other.secondDimensionValue && - additionalProperties == other.additionalProperties - } + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - private val hashCode: Int by lazy { - Objects.hash( - firstDimensionValue, - scalingFactor, - secondDimensionValue, - additionalProperties, - ) + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() } - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixScalingFactor{firstDimensionValue=$firstDimensionValue, scalingFactor=$scalingFactor, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" - } - - /** Configuration for a single tier entry with business logic */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + fun id(id: JsonField) = apply { this.id = id } /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * The key used for grouping licenses of this type. This is typically a user + * identifier field. */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** - * Returns the raw JSON value of [tierLowerBound]. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) /** - * Returns the raw JSON value of [unitAmount]. + * Sets [Builder.name] to an arbitrary JSON value. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun name(name: JsonField) = apply { this.name = name } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [LicenseType]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic - internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply } - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } + id() + groupingKey() + name() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ScalableMatrixWithTieredPricingConfig && - firstDimension == other.firstDimension && - matrixScalingFactors == other.matrixScalingFactors && - tiers == other.tiers && - secondDimension == other.secondDimension && + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - firstDimension, - matrixScalingFactors, - tiers, - secondDimension, - additionalProperties, - ) + Objects.hash(id, groupingKey, name, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricingConfig{firstDimension=$firstDimension, matrixScalingFactors=$matrixScalingFactors, tiers=$tiers, secondDimension=$secondDimension, additionalProperties=$additionalProperties}" + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -79703,7 +103354,7 @@ private constructor( return true } - return other is ScalableMatrixWithTieredPricing && + return other is CumulativeGroupedAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -79714,10 +103365,12 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && + cumulativeGroupedAllocationConfig == other.cumulativeGroupedAllocationConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -79730,9 +103383,8 @@ private constructor( planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && replacesPriceId == other.replacesPriceId && - scalableMatrixWithTieredPricingConfig == - other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -79748,10 +103400,12 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, + cumulativeGroupedAllocationConfig, currency, discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -79764,8 +103418,8 @@ private constructor( planPhaseOrder, priceType, replacesPriceId, - scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -79773,10 +103427,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class CumulativeGroupedBulk + class DailyCreditAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -79789,11 +103443,12 @@ private constructor( private val conversionRateConfig: JsonField, private val createdAt: JsonField, private val creditAllocation: JsonField, - private val cumulativeGroupedBulkConfig: JsonField, private val currency: JsonField, + private val dailyCreditAllowanceConfig: JsonField, private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -79807,6 +103462,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -79838,12 +103494,12 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - cumulativeGroupedBulkConfig: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + dailyCreditAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("discount") @ExcludeMissing discount: JsonField = JsonMissing.of(), @@ -79853,6 +103509,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -79883,6 +103542,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -79894,11 +103556,12 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, currency, + dailyCreditAllowanceConfig, discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -79912,6 +103575,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -79981,19 +103645,19 @@ private constructor( creditAllocation.getOptional("credit_allocation") /** - * Configuration for cumulative_grouped_bulk pricing - * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = - cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + fun currency(): String = currency.getRequired("currency") /** + * Configuration for daily_credit_allowance pricing + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun currency(): String = currency.getRequired("currency") + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -80015,6 +103679,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -80072,7 +103743,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_bulk") + * JsonValue.from("daily_credit_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -80114,6 +103785,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -80208,22 +103888,22 @@ private constructor( fun _creditAllocation(): JsonField = creditAllocation /** - * Returns the raw JSON value of [cumulativeGroupedBulkConfig]. + * Returns the raw JSON value of [currency]. * - * Unlike [cumulativeGroupedBulkConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - fun _cumulativeGroupedBulkConfig(): JsonField = - cumulativeGroupedBulkConfig + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** - * Returns the raw JSON value of [currency]. + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig /** * Returns the raw JSON value of [discount]. @@ -80255,6 +103935,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -80369,6 +104059,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -80384,7 +104083,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. + * Returns a mutable builder for constructing an instance of [DailyCreditAllowance]. * * The following fields are required: * ```java @@ -80398,11 +104097,12 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedBulkConfig() * .currency() + * .dailyCreditAllowanceConfig() * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -80419,7 +104119,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulk]. */ + /** A builder for [DailyCreditAllowance]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -80432,11 +104132,12 @@ private constructor( private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null private var creditAllocation: JsonField? = null - private var cumulativeGroupedBulkConfig: JsonField? = null private var currency: JsonField? = null + private var dailyCreditAllowanceConfig: JsonField? = null private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -80444,47 +104145,50 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { - id = cumulativeGroupedBulk.id - billableMetric = cumulativeGroupedBulk.billableMetric - billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration - billingMode = cumulativeGroupedBulk.billingMode - cadence = cumulativeGroupedBulk.cadence + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + id = dailyCreditAllowance.id + billableMetric = dailyCreditAllowance.billableMetric + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + billingMode = dailyCreditAllowance.billingMode + cadence = dailyCreditAllowance.cadence compositePriceFilters = - cumulativeGroupedBulk.compositePriceFilters.map { it.toMutableList() } - conversionRate = cumulativeGroupedBulk.conversionRate - conversionRateConfig = cumulativeGroupedBulk.conversionRateConfig - createdAt = cumulativeGroupedBulk.createdAt - creditAllocation = cumulativeGroupedBulk.creditAllocation - cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig - currency = cumulativeGroupedBulk.currency - discount = cumulativeGroupedBulk.discount - externalPriceId = cumulativeGroupedBulk.externalPriceId - fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity - invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration - item = cumulativeGroupedBulk.item - maximum = cumulativeGroupedBulk.maximum - maximumAmount = cumulativeGroupedBulk.maximumAmount - metadata = cumulativeGroupedBulk.metadata - minimum = cumulativeGroupedBulk.minimum - minimumAmount = cumulativeGroupedBulk.minimumAmount - modelType = cumulativeGroupedBulk.modelType - name = cumulativeGroupedBulk.name - planPhaseOrder = cumulativeGroupedBulk.planPhaseOrder - priceType = cumulativeGroupedBulk.priceType - replacesPriceId = cumulativeGroupedBulk.replacesPriceId - dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration - additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() + dailyCreditAllowance.compositePriceFilters.map { it.toMutableList() } + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + createdAt = dailyCreditAllowance.createdAt + creditAllocation = dailyCreditAllowance.creditAllocation + currency = dailyCreditAllowance.currency + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + discount = dailyCreditAllowance.discount + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = dailyCreditAllowance.invoicingCycleConfiguration + item = dailyCreditAllowance.item + maximum = dailyCreditAllowance.maximum + maximumAmount = dailyCreditAllowance.maximumAmount + metadata = dailyCreditAllowance.metadata + minimum = dailyCreditAllowance.minimum + minimumAmount = dailyCreditAllowance.minimumAmount + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + planPhaseOrder = dailyCreditAllowance.planPhaseOrder + priceType = dailyCreditAllowance.priceType + replacesPriceId = dailyCreditAllowance.replacesPriceId + dimensionalPriceConfiguration = dailyCreditAllowance.dimensionalPriceConfiguration + licenseType = dailyCreditAllowance.licenseType + additionalProperties = dailyCreditAllowance.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -80716,22 +104420,6 @@ private constructor( this.creditAllocation = creditAllocation } - /** Configuration for cumulative_grouped_bulk pricing */ - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig - ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) - - /** - * Sets [Builder.cumulativeGroupedBulkConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedBulkConfig] with a well-typed - * [CumulativeGroupedBulkConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: JsonField - ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } - fun currency(currency: String) = currency(JsonField.of(currency)) /** @@ -80743,6 +104431,21 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) + + /** + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyCreditAllowanceConfig] with a well-typed + * [DailyCreditAllowanceConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } + @Deprecated("deprecated") fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) @@ -80878,6 +104581,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -81014,7 +104738,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("cumulative_grouped_bulk") + * JsonValue.from("daily_credit_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -81114,6 +104838,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -81134,7 +104881,7 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedBulk]. + * Returns an immutable instance of [DailyCreditAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -81150,11 +104897,12 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedBulkConfig() * .currency() + * .dailyCreditAllowanceConfig() * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -81170,8 +104918,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedBulk = - CumulativeGroupedBulk( + fun build(): DailyCreditAllowance = + DailyCreditAllowance( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -81184,11 +104932,12 @@ private constructor( checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), checkRequired("creditAllocation", creditAllocation), - checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), checkRequired("currency", currency), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -81202,13 +104951,23 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedBulk = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DailyCreditAllowance = apply { if (validated) { return@apply } @@ -81223,11 +104982,12 @@ private constructor( conversionRateConfig().ifPresent { it.validate() } createdAt() creditAllocation().ifPresent { it.validate() } - cumulativeGroupedBulkConfig().validate() currency() + dailyCreditAllowanceConfig().validate() discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -81236,7 +104996,7 @@ private constructor( minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_bulk")) { + if (it != JsonValue.from("daily_credit_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -81245,6 +105005,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -81275,11 +105036,12 @@ private constructor( (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -81287,12 +105049,13 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 } + + modelType.let { if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -81385,6 +105148,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -81537,6 +105310,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -81786,6 +105569,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -81929,6 +105722,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -82061,6 +105864,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -82121,56 +105934,140 @@ private constructor( "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - /** Configuration for cumulative_grouped_bulk pricing */ - class CumulativeGroupedBulkConfig + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val dimensionValues: JsonField>, - private val group: JsonField, + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("dimension_values") + @JsonProperty("daily_allowance") @ExcludeMissing - dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("group") @ExcludeMissing group: JsonField = JsonMissing.of(), - ) : this(dimensionValues, group, mutableMapOf()) + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") + @ExcludeMissing + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) /** - * Each tier lower bound must have the same group of values. + * Credits granted per day. Lose-it-or-use-it; does not roll over. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") /** + * Default per-unit credit rate for any usage not bucketed into a specified matrix_value + * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun group(): String = group.getRequired("group") + fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") /** - * Returns the raw JSON value of [dimensionValues]. + * One or two event property values to evaluate matrix groups by * - * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** + * Event property whose value identifies the day bucket the event belongs to (e.g. + * 'event_day' set to an ISO date string in the customer's timezone). The allowance + * resets per distinct value of this property. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventDayProperty(): String = eventDayProperty.getRequired("event_day_property") + + /** + * Per-dimension credit rates + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixValues(): List = matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("dimension_values") + @JsonProperty("daily_allowance") @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues + fun _dailyAllowance(): JsonField = dailyAllowance /** - * Returns the raw JSON value of [group]. + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [group], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("group") @ExcludeMissing fun _group(): JsonField = group + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + /** + * Returns the raw JSON value of [eventDayProperty]. + * + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_day_property") + @ExcludeMissing + fun _eventDayProperty(): JsonField = eventDayProperty + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -82188,71 +106085,146 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedBulkConfig]. + * [DailyCreditAllowanceConfig]. * * The following fields are required: * ```java - * .dimensionValues() - * .group() + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulkConfig]. */ + /** A builder for [DailyCreditAllowanceConfig]. */ class Builder internal constructor() { - private var dimensionValues: JsonField>? = null - private var group: JsonField? = null + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() - @JvmSynthetic - internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = - apply { - dimensionValues = - cumulativeGroupedBulkConfig.dimensionValues.map { it.toMutableList() } - group = cumulativeGroupedBulkConfig.group - additionalProperties = - cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() - } + @JvmSynthetic + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { it.toMutableList() } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } + + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) + + /** + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyAllowance] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance + } + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) - /** Each tier lower bound must have the same group of values. */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) /** - * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * Sets [Builder.dimensions] to an arbitrary JSON value. * - * You should usually call [Builder.dimensionValues] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.dimensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** - * Adds a single [DimensionValue] to [dimensionValues]. + * Adds a single [String] to [dimensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addDimensionValue(dimensionValue: DimensionValue) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).also { - checkKnown("dimensionValues", it).add(dimensionValue) + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) } } - fun group(group: String) = group(JsonField.of(group)) + /** + * Event property whose value identifies the day bucket the event belongs to (e.g. + * 'event_day' set to an ISO date string in the customer's timezone). The allowance + * resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) /** - * Sets [Builder.group] to an arbitrary JSON value. + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. * - * You should usually call [Builder.group] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.eventDayProperty] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. */ - fun group(group: JsonField) = apply { this.group = group } + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty + } + + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -82277,35 +106249,54 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedBulkConfig]. + * Returns an immutable instance of [DailyCreditAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .dimensionValues() - * .group() + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("group", group), + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedBulkConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { if (validated) { return@apply } - dimensionValues().forEach { it.validate() } - group() + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } validated = true } @@ -82325,52 +106316,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (dimensionValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (group.asKnown().isPresent) 1 else 0) + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { (if (it == null) 0 else 1).toInt() } + ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** Configuration for a dimension value entry */ - class DimensionValue + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val tierLowerBound: JsonField, + private val dimensionValues: JsonField>, private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") + @JsonProperty("dimension_values") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), + dimensionValues: JsonField> = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), - ) : this(groupingKey, tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Grouping key value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + ) : this(dimensionValues, unitAmount, mutableMapOf()) /** - * Tier lower bound + * One or two matrix keys to filter usage to this value by. For example, ["model"] + * could be used to apply a different credit rate to each AI model. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun tierLowerBound(): String = tierLowerBound.getRequired("tier_lower_bound") + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") /** - * Unit amount for this combination + * Credits charged per unit of usage matching the specified dimension_values * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -82379,24 +106363,14 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey - - /** - * Returns the raw JSON value of [tierLowerBound]. + * Returns the raw JSON value of [dimensionValues]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has an + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("dimension_values") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _dimensionValues(): JsonField> = dimensionValues /** * Returns the raw JSON value of [unitAmount]. @@ -82423,64 +106397,62 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DimensionValue]. + * Returns a mutable builder for constructing an instance of [MatrixValue]. * * The following fields are required: * ```java - * .groupingKey() - * .tierLowerBound() + * .dimensionValues() * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [DimensionValue]. */ + /** A builder for [MatrixValue]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var tierLowerBound: JsonField? = null + private var dimensionValues: JsonField>? = null private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dimensionValue: DimensionValue) = apply { - groupingKey = dimensionValue.groupingKey - tierLowerBound = dimensionValue.tierLowerBound - unitAmount = dimensionValue.unitAmount - additionalProperties = dimensionValue.additionalProperties.toMutableMap() + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = matrixValue.additionalProperties.toMutableMap() } - /** Grouping key value */ - fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.dimensionValues] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } - /** Tier lower bound */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Adds a single [String] to [dimensionValues]. * - * You should usually call [Builder.tierLowerBound] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } } - /** Unit amount for this combination */ + /** Credits charged per unit of usage matching the specified dimension_values */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -82517,23 +106489,23 @@ private constructor( } /** - * Returns an immutable instance of [DimensionValue]. + * Returns an immutable instance of [MatrixValue]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .groupingKey() - * .tierLowerBound() + * .dimensionValues() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): DimensionValue = - DimensionValue( - checkRequired("groupingKey", groupingKey), - checkRequired("tierLowerBound", tierLowerBound), + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) @@ -82541,13 +106513,22 @@ private constructor( private var validated: Boolean = false - fun validate(): DimensionValue = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixValue = apply { if (validated) { return@apply } - groupingKey() - tierLowerBound() + dimensionValues() unitAmount() validated = true } @@ -82568,30 +106549,29 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is DimensionValue && - groupingKey == other.groupingKey && - tierLowerBound == other.tierLowerBound && + return other is MatrixValue && + dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(groupingKey, tierLowerBound, unitAmount, additionalProperties) + Objects.hash(dimensionValues, unitAmount, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "DimensionValue{groupingKey=$groupingKey, tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -82599,20 +106579,30 @@ private constructor( return true } - return other is CumulativeGroupedBulkConfig && - dimensionValues == other.dimensionValues && - group == other.group && + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(dimensionValues, group, additionalProperties) + Objects.hash( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulkConfig{dimensionValues=$dimensionValues, group=$group, additionalProperties=$additionalProperties}" + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } /** @@ -82672,159 +106662,434 @@ private constructor( } /** - * Returns an immutable instance of [Metadata]. + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmField val COMPOSITE_PRICE = of("composite_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + COMPOSITE_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + COMPOSITE_PRICE -> Value.COMPOSITE_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + COMPOSITE_PRICE -> Known.COMPOSITE_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PriceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object + * Validates that the types of all values in this object match their expected types * recursively. * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmField val COMPOSITE_PRICE = of("composite_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * 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. + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - COMPOSITE_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - COMPOSITE_PRICE -> Value.COMPOSITE_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - COMPOSITE_PRICE -> Known.COMPOSITE_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { + fun validate(): LicenseType = apply { if (validated) { return@apply } - known() + id() + groupingKey() + name() validated = true } @@ -82842,19 +107107,32 @@ 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 = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PriceType && value == other.value + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -82862,7 +107140,7 @@ private constructor( return true } - return other is CumulativeGroupedBulk && + return other is DailyCreditAllowance && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -82873,11 +107151,12 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && - cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -82891,6 +107170,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -82906,11 +107186,12 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedBulkConfig, currency, + dailyCreditAllowanceConfig, discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -82924,6 +107205,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -82931,10 +107213,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -82947,16 +107229,17 @@ private constructor( private val conversionRateConfig: JsonField, private val createdAt: JsonField, private val creditAllocation: JsonField, - private val cumulativeGroupedAllocationConfig: JsonField, private val currency: JsonField, private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, private val maximumAmount: JsonField, private val metadata: JsonField, + private val meteredAllowanceConfig: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, private val modelType: JsonValue, @@ -82965,6 +107248,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -82996,10 +107280,6 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: JsonField = - JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -83012,6 +107292,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -83023,6 +107306,9 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing @@ -83042,6 +107328,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -83053,16 +107342,17 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedAllocationConfig, currency, discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, + meteredAllowanceConfig, minimum, minimumAmount, modelType, @@ -83071,6 +107361,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -83139,15 +107430,6 @@ private constructor( fun creditAllocation(): Optional = creditAllocation.getOptional("credit_allocation") - /** - * Configuration for cumulative_grouped_allocation pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired("cumulative_grouped_allocation_config") - /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -83174,6 +107456,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -83213,6 +107502,15 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") + /** + * Configuration for metered_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -83231,7 +107529,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -83273,6 +107571,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -83366,17 +107673,6 @@ private constructor( @ExcludeMissing fun _creditAllocation(): JsonField = creditAllocation - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): JsonField = - cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [currency]. * @@ -83414,6 +107710,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -83460,6 +107766,16 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = meteredAllowanceConfig + /** * Returns the raw JSON value of [minimum]. * @@ -83528,6 +107844,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -83543,8 +107868,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java @@ -83558,16 +107882,17 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedAllocationConfig() * .currency() * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() * .maximumAmount() * .metadata() + * .meteredAllowanceConfig() * .minimum() * .minimumAmount() * .name() @@ -83579,7 +107904,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -83592,65 +107917,63 @@ private constructor( private var conversionRateConfig: JsonField? = null private var createdAt: JsonField? = null private var creditAllocation: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var currency: JsonField? = null private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null + private var meteredAllowanceConfig: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonValue = JsonValue.from("cumulative_grouped_allocation") + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = apply { - id = cumulativeGroupedAllocation.id - billableMetric = cumulativeGroupedAllocation.billableMetric - billingCycleConfiguration = cumulativeGroupedAllocation.billingCycleConfiguration - billingMode = cumulativeGroupedAllocation.billingMode - cadence = cumulativeGroupedAllocation.cadence + internal fun from(meteredAllowance: MeteredAllowance) = apply { + id = meteredAllowance.id + billableMetric = meteredAllowance.billableMetric + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + billingMode = meteredAllowance.billingMode + cadence = meteredAllowance.cadence compositePriceFilters = - cumulativeGroupedAllocation.compositePriceFilters.map { it.toMutableList() } - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - createdAt = cumulativeGroupedAllocation.createdAt - creditAllocation = cumulativeGroupedAllocation.creditAllocation - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - currency = cumulativeGroupedAllocation.currency - discount = cumulativeGroupedAllocation.discount - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - item = cumulativeGroupedAllocation.item - maximum = cumulativeGroupedAllocation.maximum - maximumAmount = cumulativeGroupedAllocation.maximumAmount - metadata = cumulativeGroupedAllocation.metadata - minimum = cumulativeGroupedAllocation.minimum - minimumAmount = cumulativeGroupedAllocation.minimumAmount - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - planPhaseOrder = cumulativeGroupedAllocation.planPhaseOrder - priceType = cumulativeGroupedAllocation.priceType - replacesPriceId = cumulativeGroupedAllocation.replacesPriceId - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() + meteredAllowance.compositePriceFilters.map { it.toMutableList() } + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + createdAt = meteredAllowance.createdAt + creditAllocation = meteredAllowance.creditAllocation + currency = meteredAllowance.currency + discount = meteredAllowance.discount + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + item = meteredAllowance.item + maximum = meteredAllowance.maximum + maximumAmount = meteredAllowance.maximumAmount + metadata = meteredAllowance.metadata + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + minimum = meteredAllowance.minimum + minimumAmount = meteredAllowance.minimumAmount + modelType = meteredAllowance.modelType + name = meteredAllowance.name + planPhaseOrder = meteredAllowance.planPhaseOrder + priceType = meteredAllowance.priceType + replacesPriceId = meteredAllowance.replacesPriceId + dimensionalPriceConfiguration = meteredAllowance.dimensionalPriceConfiguration + licenseType = meteredAllowance.licenseType + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -83882,22 +108205,6 @@ private constructor( this.creditAllocation = creditAllocation } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = cumulativeGroupedAllocationConfig(JsonField.of(cumulativeGroupedAllocationConfig)) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a well-typed - * [CumulativeGroupedAllocationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: JsonField - ) = apply { this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig } - fun currency(currency: String) = currency(JsonField.of(currency)) /** @@ -84044,6 +108351,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -84136,6 +108464,22 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig(meteredAllowanceConfig: JsonField) = + apply { + this.meteredAllowanceConfig = meteredAllowanceConfig + } + @Deprecated("deprecated") fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) @@ -84180,7 +108524,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -84280,6 +108624,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -84300,7 +108667,7 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -84316,16 +108683,17 @@ private constructor( * .conversionRateConfig() * .createdAt() * .creditAllocation() - * .cumulativeGroupedAllocationConfig() * .currency() * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() * .maximumAmount() * .metadata() + * .meteredAllowanceConfig() * .minimum() * .minimumAmount() * .name() @@ -84336,8 +108704,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -84350,19 +108718,17 @@ private constructor( checkRequired("conversionRateConfig", conversionRateConfig), checkRequired("createdAt", createdAt), checkRequired("creditAllocation", creditAllocation), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("currency", currency), checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), modelType, @@ -84371,13 +108737,23 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } @@ -84392,20 +108768,21 @@ private constructor( conversionRateConfig().ifPresent { it.validate() } createdAt() creditAllocation().ifPresent { it.validate() } - cumulativeGroupedAllocationConfig().validate() currency() discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() + meteredAllowanceConfig().validate() minimum().ifPresent { it.validate() } minimumAmount() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -84414,6 +108791,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -84444,26 +108822,26 @@ private constructor( (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (creditAllocation.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -84556,6 +108934,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -84708,6 +109096,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -84957,6 +109355,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -85100,6 +109508,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -85232,6 +109650,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -85292,54 +109720,193 @@ private constructor( "CompositePriceFilter{field=$field, operator=$operator, values=$values, additionalProperties=$additionalProperties}" } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), - ) : this(cumulativeAllocation, groupAllocation, groupingKey, unitAmount, mutableMapOf()) + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), + ) : this( + allowanceGroupingValue, + consumptionGroupingValue, + groupingKey, + unitAmount, + allowanceDisplayName, + consumptionDisplayName, + mutableMapOf(), + ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for this period + * (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at consumption — credit + * can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance quantities + * (e.g. 'event_name'). The metric is queried with this key and the two values below + * select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -85348,7 +109915,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -85357,24 +109924,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -85396,6 +109981,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -85412,12 +110017,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -85425,58 +110030,71 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties.toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for this + * period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at consumption + * — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.allowanceGroupingValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = apply { + this.allowanceGroupingValue = allowanceGroupingValue } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.consumptionGroupingValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = apply { + this.consumptionGroupingValue = consumptionGroupingValue } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the two + * values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** @@ -85490,7 +110108,7 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** Per-unit price applied to gross consumption and to the allowance credit. */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -85504,6 +110122,36 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -85527,41 +110175,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -85581,30 +110243,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -85612,114 +110280,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } class PriceType @JsonCreator private constructor(private val value: JsonField) : @@ -85819,6 +110380,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -85857,12 +110428,280 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && @@ -85873,16 +110712,17 @@ private constructor( conversionRateConfig == other.conversionRateConfig && createdAt == other.createdAt && creditAllocation == other.creditAllocation && - cumulativeGroupedAllocationConfig == other.cumulativeGroupedAllocationConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && + meteredAllowanceConfig == other.meteredAllowanceConfig && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && @@ -85891,6 +110731,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -85906,16 +110747,17 @@ private constructor( conversionRateConfig, createdAt, creditAllocation, - cumulativeGroupedAllocationConfig, currency, discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, + meteredAllowanceConfig, minimum, minimumAmount, modelType, @@ -85924,6 +110766,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -85931,7 +110774,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MeteredAllowance{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, meteredAllowanceConfig=$meteredAllowanceConfig, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class MinimumComposite @@ -85951,6 +110794,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -85965,6 +110809,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -86008,6 +110853,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -86041,6 +110889,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -86056,6 +110907,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -86070,6 +110922,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -86164,6 +111017,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -86272,6 +111132,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -86402,6 +111271,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -86526,6 +111405,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -86559,6 +111447,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -86593,6 +111482,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -86608,6 +111498,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -86627,6 +111518,7 @@ private constructor( discount = minimumComposite.discount externalPriceId = minimumComposite.externalPriceId fixedPriceQuantity = minimumComposite.fixedPriceQuantity + invoiceGroupingKey = minimumComposite.invoiceGroupingKey invoicingCycleConfiguration = minimumComposite.invoicingCycleConfiguration item = minimumComposite.item maximum = minimumComposite.maximum @@ -86641,6 +111533,7 @@ private constructor( priceType = minimumComposite.priceType replacesPriceId = minimumComposite.replacesPriceId dimensionalPriceConfiguration = minimumComposite.dimensionalPriceConfiguration + licenseType = minimumComposite.licenseType additionalProperties = minimumComposite.additionalProperties.toMutableMap() } @@ -87019,6 +111912,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -87271,6 +112185,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -87311,6 +112248,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -87345,6 +112283,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -87359,12 +112298,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MinimumComposite = apply { if (validated) { return@apply @@ -87384,6 +112333,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -87402,6 +112352,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -87436,6 +112387,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -87449,7 +112401,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -87542,6 +112495,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -87694,6 +112657,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -87943,6 +112916,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -88086,6 +113069,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -88218,6 +113211,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -88344,6 +113347,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -88551,6 +113564,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): MinimumCompositeConfig = apply { if (validated) { return@apply @@ -88698,6 +113721,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -88736,6 +113769,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -88756,6 +114057,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -88770,6 +114072,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -88789,6 +114092,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -88803,6 +114107,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -88810,7 +114115,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MinimumComposite{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MinimumComposite{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, minimumCompositeConfig=$minimumCompositeConfig, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class Percent @@ -88830,6 +114135,7 @@ private constructor( private val discount: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -88844,6 +114150,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -88887,6 +114194,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -88920,6 +114230,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -88935,6 +114248,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -88949,6 +114263,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -89043,6 +114358,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -89150,6 +114472,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -89280,6 +114611,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -89404,6 +114745,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -89437,6 +114787,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -89471,6 +114822,7 @@ private constructor( private var discount: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -89486,6 +114838,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -89504,6 +114857,7 @@ private constructor( discount = percent.discount externalPriceId = percent.externalPriceId fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration item = percent.item maximum = percent.maximum @@ -89518,6 +114872,7 @@ private constructor( priceType = percent.priceType replacesPriceId = percent.replacesPriceId dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + licenseType = percent.licenseType additionalProperties = percent.additionalProperties.toMutableMap() } @@ -89896,6 +115251,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -90147,6 +115523,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -90187,6 +115586,7 @@ private constructor( * .discount() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -90221,6 +115621,7 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -90235,12 +115636,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -90260,6 +115671,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -90278,6 +115690,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -90312,6 +115725,7 @@ private constructor( (discount.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -90325,7 +115739,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -90418,6 +115833,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -90570,6 +115995,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -90819,6 +116254,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -90962,6 +116407,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -91094,6 +116549,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -91220,6 +116685,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -91384,6 +116859,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -91524,6 +117009,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -91562,6 +117057,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -91582,6 +117345,7 @@ private constructor( discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -91596,6 +117360,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -91615,6 +117380,7 @@ private constructor( discount, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -91629,6 +117395,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -91636,7 +117403,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, percentConfig=$percentConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Percent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, percentConfig=$percentConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, additionalProperties=$additionalProperties}" } class EventOutput @@ -91657,6 +117424,7 @@ private constructor( private val eventOutputConfig: JsonField, private val externalPriceId: JsonField, private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, private val item: JsonField, private val maximum: JsonField, @@ -91670,6 +117438,7 @@ private constructor( private val priceType: JsonField, private val replacesPriceId: JsonField, private val dimensionalPriceConfiguration: JsonField, + private val licenseType: JsonField, private val additionalProperties: MutableMap, ) { @@ -91716,6 +117485,9 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), @@ -91746,6 +117518,9 @@ private constructor( @ExcludeMissing dimensionalPriceConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type") + @ExcludeMissing + licenseType: JsonField = JsonMissing.of(), ) : this( id, billableMetric, @@ -91762,6 +117537,7 @@ private constructor( eventOutputConfig, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -91775,6 +117551,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, mutableMapOf(), ) @@ -91878,6 +117655,13 @@ private constructor( fun fixedPriceQuantity(): Optional = fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -91977,6 +117761,15 @@ private constructor( fun dimensionalPriceConfiguration(): Optional = dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseType(): Optional = licenseType.getOptional("license_type") + /** * Returns the raw JSON value of [id]. * @@ -92117,6 +117910,16 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** * Returns the raw JSON value of [invoicingCycleConfiguration]. * @@ -92231,6 +118034,15 @@ private constructor( fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration + /** + * Returns the raw JSON value of [licenseType]. + * + * Unlike [licenseType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("license_type") + @ExcludeMissing + fun _licenseType(): JsonField = licenseType + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -92265,6 +118077,7 @@ private constructor( * .eventOutputConfig() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -92299,6 +118112,7 @@ private constructor( private var eventOutputConfig: JsonField? = null private var externalPriceId: JsonField? = null private var fixedPriceQuantity: JsonField? = null + private var invoiceGroupingKey: JsonField? = null private var invoicingCycleConfiguration: JsonField? = null private var item: JsonField? = null private var maximum: JsonField? = null @@ -92313,6 +118127,7 @@ private constructor( private var replacesPriceId: JsonField? = null private var dimensionalPriceConfiguration: JsonField = JsonMissing.of() + private var licenseType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -92332,6 +118147,7 @@ private constructor( eventOutputConfig = eventOutput.eventOutputConfig externalPriceId = eventOutput.externalPriceId fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration item = eventOutput.item maximum = eventOutput.maximum @@ -92345,6 +118161,7 @@ private constructor( priceType = eventOutput.priceType replacesPriceId = eventOutput.replacesPriceId dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + licenseType = eventOutput.licenseType additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -92738,6 +118555,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + fun invoicingCycleConfiguration( invoicingCycleConfiguration: BillingCycleConfiguration? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) @@ -92974,6 +118812,29 @@ private constructor( dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping + * key. + */ + fun licenseType(licenseType: LicenseType?) = + licenseType(JsonField.ofNullable(licenseType)) + + /** Alias for calling [Builder.licenseType] with `licenseType.orElse(null)`. */ + fun licenseType(licenseType: Optional) = + licenseType(licenseType.getOrNull()) + + /** + * Sets [Builder.licenseType] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseType] with a well-typed [LicenseType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licenseType(licenseType: JsonField) = apply { + this.licenseType = licenseType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -93015,6 +118876,7 @@ private constructor( * .eventOutputConfig() * .externalPriceId() * .fixedPriceQuantity() + * .invoiceGroupingKey() * .invoicingCycleConfiguration() * .item() * .maximum() @@ -93049,6 +118911,7 @@ private constructor( checkRequired("eventOutputConfig", eventOutputConfig), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoiceGroupingKey", invoiceGroupingKey), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -93062,12 +118925,22 @@ private constructor( checkRequired("priceType", priceType), checkRequired("replacesPriceId", replacesPriceId), dimensionalPriceConfiguration, + licenseType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -93088,6 +118961,7 @@ private constructor( eventOutputConfig().validate() externalPriceId() fixedPriceQuantity() + invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -93105,6 +118979,7 @@ private constructor( priceType().validate() replacesPriceId() dimensionalPriceConfiguration().ifPresent { it.validate() } + licenseType().ifPresent { it.validate() } validated = true } @@ -93140,6 +119015,7 @@ private constructor( (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (item.asKnown().getOrNull()?.validity() ?: 0) + (maximum.asKnown().getOrNull()?.validity() ?: 0) + @@ -93152,7 +119028,8 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (licenseType.asKnown().getOrNull()?.validity() ?: 0) class BillingMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -93245,6 +119122,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BillingMode = apply { if (validated) { return@apply @@ -93397,6 +119284,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -93646,6 +119543,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CompositePriceFilter = apply { if (validated) { return@apply @@ -93789,6 +119696,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -93921,6 +119838,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply @@ -94211,6 +120138,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -94330,6 +120267,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -94468,6 +120415,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceType = apply { if (validated) { return@apply @@ -94506,6 +120463,274 @@ private constructor( override fun toString() = value.toString() } + /** + * The LicenseType resource represents a type of license that can be assigned to users. + * License types are used during billing by grouping metrics on the configured grouping key. + */ + class LicenseType + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val groupingKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, groupingKey, name, mutableMapOf()) + + /** + * The Orb-assigned unique identifier for the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * The key used for grouping licenses of this type. This is typically a user identifier + * field. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The name of the license type. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LicenseType]. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LicenseType]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var groupingKey: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(licenseType: LicenseType) = apply { + id = licenseType.id + groupingKey = licenseType.groupingKey + name = licenseType.name + additionalProperties = licenseType.additionalProperties.toMutableMap() + } + + /** The Orb-assigned unique identifier for the license type. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The key used for grouping licenses of this type. This is typically a user + * identifier field. + */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The name of the license type. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LicenseType]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .groupingKey() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LicenseType = + LicenseType( + checkRequired("id", id), + checkRequired("groupingKey", groupingKey), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): LicenseType = apply { + if (validated) { + return@apply + } + + id() + groupingKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LicenseType && + id == other.id && + groupingKey == other.groupingKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, groupingKey, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LicenseType{id=$id, groupingKey=$groupingKey, name=$name, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -94527,6 +120752,7 @@ private constructor( eventOutputConfig == other.eventOutputConfig && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && @@ -94540,6 +120766,7 @@ private constructor( priceType == other.priceType && replacesPriceId == other.replacesPriceId && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + licenseType == other.licenseType && additionalProperties == other.additionalProperties } @@ -94560,6 +120787,7 @@ private constructor( eventOutputConfig, externalPriceId, fixedPriceQuantity, + invoiceGroupingKey, invoicingCycleConfiguration, item, maximum, @@ -94573,6 +120801,7 @@ private constructor( priceType, replacesPriceId, dimensionalPriceConfiguration, + licenseType, additionalProperties, ) } @@ -94580,6 +120809,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, eventOutputConfig=$eventOutputConfig, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "EventOutput{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, billingMode=$billingMode, cadence=$cadence, compositePriceFilters=$compositePriceFilters, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, eventOutputConfig=$eventOutputConfig, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, replacesPriceId=$replacesPriceId, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, licenseType=$licenseType, 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 33805bc5d..96491b926 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 @@ -147,6 +147,13 @@ private constructor( fun body(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = body(Body.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [body] with + * `Body.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun body(matrixWithThresholdDiscounts: Body.MatrixWithThresholdDiscounts) = + body(Body.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** Alias for calling [body] with `Body.ofTieredWithProration(tieredWithProration)`. */ fun body(tieredWithProration: NewFloatingTieredWithProrationPrice) = body(Body.ofTieredWithProration(tieredWithProration)) @@ -221,6 +228,14 @@ private constructor( fun body(cumulativeGroupedAllocation: Body.CumulativeGroupedAllocation) = body(Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [body] with `Body.ofDailyCreditAllowance(dailyCreditAllowance)`. */ + fun body(dailyCreditAllowance: Body.DailyCreditAllowance) = + body(Body.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [body] with `Body.ofMeteredAllowance(meteredAllowance)`. */ + fun body(meteredAllowance: Body.MeteredAllowance) = + body(Body.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [body] with `Body.ofMinimumComposite(minimumComposite)`. */ fun body(minimumComposite: NewFloatingMinimumCompositePrice) = body(Body.ofMinimumComposite(minimumComposite)) @@ -374,6 +389,7 @@ private constructor( private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, private val unitWithPercent: NewFloatingUnitWithPercentPrice? = null, private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, private val tieredWithProration: NewFloatingTieredWithProrationPrice? = null, private val unitWithProration: NewFloatingUnitWithProrationPrice? = null, private val groupedAllocation: NewFloatingGroupedAllocationPrice? = null, @@ -391,6 +407,8 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, private val minimumComposite: NewFloatingMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -433,6 +451,9 @@ private constructor( fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -477,6 +498,11 @@ private constructor( fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = Optional.ofNullable(meteredAllowance) + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) @@ -512,6 +538,8 @@ private constructor( fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null @@ -540,6 +568,10 @@ private constructor( fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + fun isMinimumComposite(): Boolean = minimumComposite != null fun isPercent(): Boolean = percent != null @@ -582,6 +614,9 @@ private constructor( fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + fun asTieredWithProration(): NewFloatingTieredWithProrationPrice = tieredWithProration.getOrThrow("tieredWithProration") @@ -624,6 +659,11 @@ private constructor( fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = meteredAllowance.getOrThrow("meteredAllowance") + fun asMinimumComposite(): NewFloatingMinimumCompositePrice = minimumComposite.getOrThrow("minimumComposite") @@ -633,6 +673,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = body.accept(new Body.Visitor>() { + * @Override + * public Optional visitUnit(NewFloatingUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) @@ -653,6 +722,8 @@ private constructor( unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) @@ -677,6 +748,9 @@ private constructor( visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) cumulativeGroupedAllocation != null -> visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -685,6 +759,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -760,6 +843,12 @@ private constructor( matrixWithAllocation.validate() } + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) { @@ -845,6 +934,16 @@ private constructor( cumulativeGroupedAllocation.validate() } + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + override fun visitMinimumComposite( minimumComposite: NewFloatingMinimumCompositePrice ) { @@ -925,6 +1024,10 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ) = matrixWithAllocation.validity() + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = tieredWithProration.validity() @@ -982,6 +1085,13 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + override fun visitMinimumComposite( minimumComposite: NewFloatingMinimumCompositePrice ) = minimumComposite.validity() @@ -1014,6 +1124,7 @@ private constructor( packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && @@ -1028,6 +1139,8 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && minimumComposite == other.minimumComposite && percent == other.percent && eventOutput == other.eventOutput @@ -1049,6 +1162,7 @@ private constructor( packageWithAllocation, unitWithPercent, matrixWithAllocation, + matrixWithThresholdDiscounts, tieredWithProration, unitWithProration, groupedAllocation, @@ -1063,6 +1177,8 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, minimumComposite, percent, eventOutput, @@ -1086,6 +1202,8 @@ private constructor( "Body{packageWithAllocation=$packageWithAllocation}" unitWithPercent != null -> "Body{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> "Body{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Body{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" tieredWithProration != null -> "Body{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Body{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Body{groupedAllocation=$groupedAllocation}" @@ -1109,6 +1227,8 @@ private constructor( "Body{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> "Body{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> "Body{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Body{meteredAllowance=$meteredAllowance}" minimumComposite != null -> "Body{minimumComposite=$minimumComposite}" percent != null -> "Body{percent=$percent}" eventOutput != null -> "Body{eventOutput=$eventOutput}" @@ -1166,6 +1286,11 @@ private constructor( fun ofMatrixWithAllocation(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = Body(matrixWithAllocation = matrixWithAllocation) + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Body(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + @JvmStatic fun ofTieredWithProration(tieredWithProration: NewFloatingTieredWithProrationPrice) = Body(tieredWithProration = tieredWithProration) @@ -1231,6 +1356,14 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = Body(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Body(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Body(meteredAllowance = meteredAllowance) + @JvmStatic fun ofMinimumComposite(minimumComposite: NewFloatingMinimumCompositePrice) = Body(minimumComposite = minimumComposite) @@ -1279,6 +1412,10 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ): T + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ): T @@ -1329,6 +1466,10 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + fun visitMinimumComposite(minimumComposite: NewFloatingMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -1441,6 +1582,11 @@ private constructor( ?.let { Body(matrixWithAllocation = it, _json = json) } ?: Body(_json = json) } + "matrix_with_threshold_discounts" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(matrixWithThresholdDiscounts = it, _json = json) } + ?: Body(_json = json) + } "tiered_with_proration" -> { return tryDeserialize( node, @@ -1547,6 +1693,16 @@ private constructor( ?.let { Body(cumulativeGroupedAllocation = it, _json = json) } ?: Body(_json = json) } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(dailyCreditAllowance = it, _json = json) + } ?: Body(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(meteredAllowance = it, _json = json) + } ?: Body(_json = json) + } "minimum_composite" -> { return tryDeserialize( node, @@ -1598,6 +1754,8 @@ private constructor( value.unitWithPercent != null -> generator.writeObject(value.unitWithPercent) value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> @@ -1626,6 +1784,9 @@ private constructor( generator.writeObject(value.cumulativeGroupedBulk) value.cumulativeGroupedAllocation != null -> generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> generator.writeObject(value.meteredAllowance) value.minimumComposite != null -> generator.writeObject(value.minimumComposite) value.percent != null -> generator.writeObject(value.percent) value.eventOutput != null -> generator.writeObject(value.eventOutput) @@ -1654,6 +1815,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -1707,6 +1869,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -1727,6 +1892,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -1881,6 +2047,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -2033,6 +2207,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -2095,6 +2279,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2116,6 +2301,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -2516,6 +2702,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -2591,6 +2796,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -2598,6 +2804,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): BulkWithFilters = apply { if (validated) { return@apply @@ -2623,6 +2839,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -2659,6 +2876,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -2855,6 +3073,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply @@ -3057,6 +3285,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -3284,6 +3522,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -3473,6 +3721,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -3577,6 +3835,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -3642,6 +3910,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -3664,6 +3933,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -3672,17 +3942,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class MatrixWithThresholdDiscounts @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -3695,6 +3965,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -3707,13 +3978,13 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: JsonField = + JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @@ -3749,14 +4020,17 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, currency, - groupedWithMinMaxThresholdsConfig, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, billableMetricId, @@ -3769,6 +4043,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -3792,32 +4067,32 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for matrix_with_threshold_discounts pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -3925,6 +4200,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -3951,22 +4234,22 @@ private constructor( @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [itemId]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): JsonField = - groupedWithMinMaxThresholdsConfig + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** - * Returns the raw JSON value of [itemId]. + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = matrixWithThresholdDiscountsConfig /** * Returns the raw JSON value of [name]. @@ -4078,6 +4361,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -4104,30 +4397,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [MatrixWithThresholdDiscounts]. * * The following fields are required: * ```java * .cadence() * .currency() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [MatrixWithThresholdDiscounts]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("grouped_with_min_max_thresholds") + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null + private var modelType: JsonValue = JsonValue.from("matrix_with_threshold_discounts") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -4143,35 +4436,37 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = apply { - cadence = groupedWithMinMaxThresholds.cadence - currency = groupedWithMinMaxThresholds.currency - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = matrixWithThresholdDiscounts.cadence + currency = matrixWithThresholdDiscounts.currency + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -4198,27 +4493,6 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -4231,13 +4505,35 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to the * following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -4575,6 +4871,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -4617,7 +4932,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4625,22 +4940,22 @@ private constructor( * ```java * .cadence() * .currency() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( checkRequired("cadence", cadence), checkRequired("currency", currency), + checkRequired("itemId", itemId), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, ), - checkRequired("itemId", itemId), modelType, checkRequired("name", name), billableMetricId, @@ -4653,6 +4968,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -4660,17 +4976,27 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { if (validated) { return@apply } cadence().validate() currency() - groupedWithMinMaxThresholdsConfig().validate() itemId() + matrixWithThresholdDiscountsConfig().validate() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -4685,6 +5011,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -4707,10 +5034,10 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() ?: 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -4723,6 +5050,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -4843,6 +5171,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -4881,108 +5219,139 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Unit price used for usage that does not match any defined matrix cell. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The maximum amount to charge each group + * First matrix dimension key. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") /** - * The minimum amount to charge each group, regardless of usage + * Per-cell unit prices. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun matrixValues(): List = matrixValues.getRequired("matrix_values") /** - * The base price charged per group + * Optional second matrix dimension key. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") /** - * Returns the raw JSON value of [groupingKey]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [firstDimension]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [firstDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("first_dimension") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _firstDimension(): JsonField = firstDimension /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("matrix_values") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _matrixValues(): JsonField> = matrixValues /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [secondDimension]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [secondDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("second_dimension") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -5000,199 +5369,6663 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [MatrixWithThresholdDiscountsConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() + matrixWithThresholdDiscountsConfig.additionalProperties.toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + /** Unit price used for usage that does not match any defined matrix cell. */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.firstDimension] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed [String] + * You should usually call [Builder.firstDimension] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed [String] + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThresholdDiscountGroup(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this(firstDimensionValue, unitAmount, secondDimensionValue, 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = matrixValue.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = apply { + this.firstDimensionValue = firstDimensionValue + } + + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this group. + * Each coordinate is `first,second` when the matrix has two dimensions, or just + * `first` for a single-dimension matrix. Example: `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cellCoordinates(): String = cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun thresholdAmount(): String = thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): JsonField = + groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + currency = groupedWithMinMaxThresholds.currency + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties.toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + currency == other.currency && + groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): JsonField = + cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("cumulative_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) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties.toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == other.cumulativeGroupedAllocationConfig && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class DailyCreditAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val dailyCreditAllowanceConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + dailyCreditAllowanceConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + dailyCreditAllowanceConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for daily_credit_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRate(): Optional = conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. + * + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DailyCreditAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DailyCreditAllowance]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var dailyCreditAllowanceConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + currency = dailyCreditAllowance.currency + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + additionalProperties = dailyCreditAllowance.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) + + /** + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyCreditAllowanceConfig] with a well-typed + * [DailyCreditAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun conversionRateConfig(conversionRateConfig: JsonField) = + apply { + this.conversionRateConfig = conversionRateConfig + } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a well-typed + * [NewDimensionalPriceConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowance = + DailyCreditAllowance( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DailyCreditAllowance = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + dailyCreditAllowanceConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("daily_credit_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("daily_allowance") + @ExcludeMissing + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") + @ExcludeMissing + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) + + /** + * Credits granted per day. Lose-it-or-use-it; does not roll over. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** + * One or two event property values to evaluate matrix groups by + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** + * Event property whose value identifies the day bucket the event belongs to (e.g. + * 'event_day' set to an ISO date string in the customer's timezone). The allowance + * resets per distinct value of this property. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventDayProperty(): String = eventDayProperty.getRequired("event_day_property") + + /** + * Per-dimension credit rates + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixValues(): List = matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("daily_allowance") + @ExcludeMissing + fun _dailyAllowance(): JsonField = dailyAllowance + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + /** + * Returns the raw JSON value of [eventDayProperty]. + * + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_day_property") + @ExcludeMissing + fun _eventDayProperty(): JsonField = eventDayProperty + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowanceConfig]. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DailyCreditAllowanceConfig]. */ + class Builder internal constructor() { + + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { it.toMutableList() } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } + + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) + + /** + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyAllowance] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance + } + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) + + /** + * Sets [Builder.dimensions] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) + + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty + } + + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified dimension_values + */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = perUnitRate(JsonField.of(perUnitRate)) + private var validated: Boolean = false /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Validates that the types of all values in this object match their expected + * types recursively. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): MatrixValue = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + dimensionValues() + unitAmount() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, additionalProperties, ) } @@ -5200,7 +12033,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } /** @@ -5269,6 +12102,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -5317,10 +12160,10 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is DailyCreditAllowance && cadence == other.cadence && currency == other.currency && - groupedWithMinMaxThresholdsConfig == other.groupedWithMinMaxThresholdsConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -5334,6 +12177,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -5342,7 +12186,7 @@ private constructor( Objects.hash( cadence, currency, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -5356,6 +12200,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -5364,17 +12209,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, currency=$currency, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val currency: JsonField, private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -5387,6 +12231,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -5396,16 +12241,15 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: JsonField = - JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @@ -5441,14 +12285,17 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, currency, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -5461,6 +12308,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -5475,41 +12323,39 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * An ISO 4217 currency string for which this price is billed in. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun currency(): String = currency.getRequired("currency") /** - * An ISO 4217 currency string for which this price is billed in. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun currency(): String = currency.getRequired("currency") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for metered_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5617,6 +12463,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5634,17 +12488,6 @@ private constructor( */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): JsonField = - cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [currency]. * @@ -5660,6 +12503,17 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + /** * Returns the raw JSON value of [name]. * @@ -5770,6 +12624,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5795,31 +12659,28 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .currency() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("cumulative_grouped_allocation") + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -5835,36 +12696,32 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - currency = cumulativeGroupedAllocation.currency - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + currency = meteredAllowance.currency + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + dimensionalPriceConfiguration = meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -5878,27 +12735,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** An ISO 4217 currency string for which this price is billed in. */ fun currency(currency: String) = currency(JsonField.of(currency)) @@ -5923,13 +12759,28 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + /** * 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("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6263,9 +13114,28 @@ private constructor( * [NewBillingCycleConfiguration] value instead. This method is primarily for * setting the field to an undocumented or not yet supported value. */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -6309,30 +13179,27 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .currency() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("currency", currency), checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), modelType, checkRequired("name", name), billableMetricId, @@ -6345,6 +13212,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -6352,17 +13220,27 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() currency() itemId() + meteredAllowanceConfig().validate() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -6377,6 +13255,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -6398,12 +13277,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -6415,6 +13292,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -6535,6 +13413,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -6573,60 +13461,76 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), ) : this( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, mutableMapOf(), ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for this + * period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at consumption + * — credit can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the two + * values below select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -6635,7 +13539,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected @@ -6644,24 +13548,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("cumulative_allocation") + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -6683,6 +13605,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -6699,12 +13641,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -6712,59 +13654,72 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties.toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed + * You should usually call [Builder.allowanceGroupingValue] with a well-typed * [String] value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = apply { + this.allowanceGroupingValue = allowanceGroupingValue } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed [String] - * value instead. This method is primarily for setting the field to an + * You should usually call [Builder.consumptionGroupingValue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) /** @@ -6778,7 +13733,7 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** Per-unit price applied to gross consumption and to the allowance credit. */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -6792,6 +13747,36 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -6815,41 +13800,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -6869,30 +13868,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -6900,7 +13905,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } /** @@ -6969,6 +13974,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -7017,11 +14032,11 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && cadence == other.cadence && - cumulativeGroupedAllocationConfig == other.cumulativeGroupedAllocationConfig && currency == other.currency && itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -7034,6 +14049,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -7041,9 +14057,9 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, currency, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -7056,6 +14072,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -7064,7 +14081,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MeteredAllowance{cadence=$cadence, currency=$currency, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -7086,6 +14103,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -7139,6 +14157,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -7159,6 +14180,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -7312,6 +14334,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7464,6 +14494,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7526,6 +14566,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7547,6 +14588,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -7946,6 +14988,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -8021,6 +15082,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -8028,6 +15090,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -8053,6 +15125,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -8089,6 +15162,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8209,6 +15283,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -8371,6 +15455,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -8481,6 +15575,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -8546,6 +15650,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8568,6 +15673,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8576,7 +15682,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -8598,6 +15704,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8651,6 +15758,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8671,6 +15781,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8825,6 +15936,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by @@ -8977,6 +16096,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9039,6 +16168,7 @@ private constructor( private var invoiceGroupingKey: JsonField = JsonMissing.of() private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9060,6 +16190,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -9459,6 +16590,25 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9534,6 +16684,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9541,6 +16692,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -9566,6 +16727,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -9602,6 +16764,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -9722,6 +16885,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -9992,6 +17165,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -10111,6 +17294,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -10176,6 +17369,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -10198,6 +17392,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -10206,7 +17401,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt index d92a665b7..ae414e4f9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleParams.kt @@ -745,6 +745,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -817,6 +826,7 @@ private constructor( private val externalPriceId: JsonField, private val filter: JsonField, private val groupingKeys: JsonField>, + private val metricParameterOverrides: JsonField, private val price: JsonField, private val priceId: JsonField, private val additionalProperties: MutableMap, @@ -831,9 +841,20 @@ private constructor( @JsonProperty("grouping_keys") @ExcludeMissing groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, filter, groupingKeys, price, priceId, mutableMapOf()) + ) : this( + externalPriceId, + filter, + groupingKeys, + metricParameterOverrides, + price, + priceId, + mutableMapOf(), + ) /** * The external ID of a price to evaluate that exists in your Orb account. @@ -862,6 +883,16 @@ private constructor( */ fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * New floating price request body params. * @@ -905,6 +936,17 @@ private constructor( @ExcludeMissing fun _groupingKeys(): JsonField> = groupingKeys + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [price]. * @@ -943,6 +985,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var groupingKeys: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -952,6 +996,7 @@ private constructor( externalPriceId = priceEvaluation.externalPriceId filter = priceEvaluation.filter groupingKeys = priceEvaluation.groupingKeys.map { it.toMutableList() } + metricParameterOverrides = priceEvaluation.metricParameterOverrides price = priceEvaluation.price priceId = priceEvaluation.priceId additionalProperties = priceEvaluation.additionalProperties.toMutableMap() @@ -1024,6 +1069,32 @@ private constructor( } } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** New floating price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) @@ -1100,6 +1171,13 @@ private constructor( fun price(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -1189,6 +1267,16 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: NewFloatingMinimumCompositePrice) = price(Price.ofMinimumComposite(minimumComposite)) @@ -1243,6 +1331,7 @@ private constructor( externalPriceId, filter, (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, price, priceId, additionalProperties.toMutableMap(), @@ -1251,6 +1340,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceEvaluation = apply { if (validated) { return@apply @@ -1259,6 +1357,7 @@ private constructor( externalPriceId() filter() groupingKeys() + metricParameterOverrides().ifPresent { it.validate() } price().ifPresent { it.validate() } priceId() validated = true @@ -1283,9 +1382,133 @@ private constructor( (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (filter.asKnown().isPresent) 1 else 0) + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + class MetricParameterOverrides + @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 + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -1305,6 +1528,7 @@ private constructor( private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, private val unitWithPercent: NewFloatingUnitWithPercentPrice? = null, private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, private val tieredWithProration: NewFloatingTieredWithProrationPrice? = null, private val unitWithProration: NewFloatingUnitWithProrationPrice? = null, private val groupedAllocation: NewFloatingGroupedAllocationPrice? = null, @@ -1325,6 +1549,8 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, private val minimumComposite: NewFloatingMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -1367,6 +1593,9 @@ private constructor( fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -1411,6 +1640,12 @@ private constructor( fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) @@ -1446,6 +1681,8 @@ private constructor( fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null @@ -1475,6 +1712,10 @@ private constructor( fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + fun isMinimumComposite(): Boolean = minimumComposite != null fun isPercent(): Boolean = percent != null @@ -1517,6 +1758,9 @@ private constructor( fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + fun asTieredWithProration(): NewFloatingTieredWithProrationPrice = tieredWithProration.getOrThrow("tieredWithProration") @@ -1560,6 +1804,12 @@ private constructor( fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + fun asMinimumComposite(): NewFloatingMinimumCompositePrice = minimumComposite.getOrThrow("minimumComposite") @@ -1569,6 +1819,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewFloatingUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) @@ -1589,6 +1869,8 @@ private constructor( unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) @@ -1616,6 +1898,9 @@ private constructor( visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) cumulativeGroupedAllocation != null -> visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -1624,6 +1909,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Price = apply { if (validated) { return@apply @@ -1703,6 +1998,12 @@ private constructor( matrixWithAllocation.validate() } + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) { @@ -1789,6 +2090,16 @@ private constructor( cumulativeGroupedAllocation.validate() } + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + override fun visitMinimumComposite( minimumComposite: NewFloatingMinimumCompositePrice ) { @@ -1871,6 +2182,10 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ) = matrixWithAllocation.validity() + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = tieredWithProration.validity() @@ -1929,6 +2244,13 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + override fun visitMinimumComposite( minimumComposite: NewFloatingMinimumCompositePrice ) = minimumComposite.validity() @@ -1962,6 +2284,7 @@ private constructor( packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && @@ -1976,6 +2299,8 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && minimumComposite == other.minimumComposite && percent == other.percent && eventOutput == other.eventOutput @@ -1997,6 +2322,7 @@ private constructor( packageWithAllocation, unitWithPercent, matrixWithAllocation, + matrixWithThresholdDiscounts, tieredWithProration, unitWithProration, groupedAllocation, @@ -2011,6 +2337,8 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, minimumComposite, percent, eventOutput, @@ -2036,6 +2364,8 @@ private constructor( unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" @@ -2060,6 +2390,9 @@ private constructor( "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -2120,6 +2453,11 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ) = Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + @JvmStatic fun ofTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice @@ -2187,6 +2525,14 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + @JvmStatic fun ofMinimumComposite(minimumComposite: NewFloatingMinimumCompositePrice) = Price(minimumComposite = minimumComposite) @@ -2238,6 +2584,10 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ): T + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ): T @@ -2288,6 +2638,10 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + fun visitMinimumComposite(minimumComposite: NewFloatingMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -2406,6 +2760,14 @@ private constructor( ?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } "tiered_with_proration" -> { return tryDeserialize( node, @@ -2520,6 +2882,16 @@ private constructor( ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } ?: Price(_json = json) } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } "minimum_composite" -> { return tryDeserialize( node, @@ -2573,6 +2945,8 @@ private constructor( generator.writeObject(value.unitWithPercent) value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> @@ -2601,6 +2975,10 @@ private constructor( generator.writeObject(value.cumulativeGroupedBulk) value.cumulativeGroupedAllocation != null -> generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) value.minimumComposite != null -> generator.writeObject(value.minimumComposite) value.percent != null -> generator.writeObject(value.percent) @@ -2631,6 +3009,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -2688,6 +3067,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -2708,6 +3090,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -2866,6 +3249,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -3026,6 +3417,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3090,6 +3491,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3112,6 +3514,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -3523,6 +3926,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -3598,6 +4022,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -3605,6 +4030,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): BulkWithFilters = apply { if (validated) { return@apply @@ -3630,6 +4065,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -3666,6 +4102,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -3867,6 +4304,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply @@ -4070,6 +4517,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -4299,6 +4756,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -4490,6 +4957,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -4596,6 +5073,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -4662,6 +5149,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -4684,6 +5172,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -4692,17 +5181,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class MatrixWithThresholdDiscounts @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -4716,6 +5205,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -4728,14 +5218,14 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -4775,14 +5265,17 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, currency, - groupedWithMinMaxThresholdsConfig, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, billableMetricId, @@ -4795,6 +5288,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -4818,32 +5312,32 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for matrix_with_threshold_discounts pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -4955,6 +5449,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -4986,23 +5488,24 @@ private constructor( fun _currency(): JsonField = currency /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [itemId]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** - * Returns the raw JSON value of [itemId]. + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig /** * Returns the raw JSON value of [name]. @@ -5115,6 +5618,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5141,31 +5654,31 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [MatrixWithThresholdDiscounts]. * * The following fields are required: * ```java * .cadence() * .currency() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [MatrixWithThresholdDiscounts]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + JsonValue.from("matrix_with_threshold_discounts") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -5183,35 +5696,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = apply { - cadence = groupedWithMinMaxThresholds.cadence - currency = groupedWithMinMaxThresholds.currency - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = matrixWithThresholdDiscounts.cadence + currency = matrixWithThresholdDiscounts.currency + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -5238,29 +5753,6 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -5273,13 +5765,36 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -5629,6 +6144,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -5671,7 +6207,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -5679,22 +6215,22 @@ private constructor( * ```java * .cadence() * .currency() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( checkRequired("cadence", cadence), checkRequired("currency", currency), + checkRequired("itemId", itemId), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, ), - checkRequired("itemId", itemId), modelType, checkRequired("name", name), billableMetricId, @@ -5707,6 +6243,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -5714,17 +6251,27 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { if (validated) { return@apply } cadence().validate() currency() - groupedWithMinMaxThresholdsConfig().validate() itemId() + matrixWithThresholdDiscountsConfig().validate() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -5739,6 +6286,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -5761,10 +6309,11 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -5777,6 +6326,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -5899,6 +6449,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -5938,108 +6498,140 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Unit price used for usage that does not match any defined matrix cell. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The maximum amount to charge each group + * First matrix dimension key. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") /** - * The minimum amount to charge each group, regardless of usage + * Per-cell unit prices. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") /** - * The base price charged per group + * Optional second matrix dimension key. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") /** - * Returns the raw JSON value of [groupingKey]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [firstDimension]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [firstDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("first_dimension") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _firstDimension(): JsonField = firstDimension /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("matrix_values") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _matrixValues(): JsonField> = matrixValues /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [secondDimension]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [secondDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("second_dimension") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -6057,203 +6649,6848 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [MatrixWithThresholdDiscountsConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties + matrixWithThresholdDiscountsConfig.additionalProperties .toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** + * Unit price used for usage that does not match any defined matrix cell. + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.firstDimension] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.firstDimension] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + currency = groupedWithMinMaxThresholds.currency + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + currency == other.currency && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("cumulative_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) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class DailyCreditAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val dailyCreditAllowanceConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + dailyCreditAllowanceConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + dailyCreditAllowanceConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for daily_credit_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. + * + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DailyCreditAllowance]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var dailyCreditAllowanceConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + currency = dailyCreditAllowance.currency + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) + + /** + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowance = + DailyCreditAllowance( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + dailyCreditAllowanceConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("daily_credit_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("daily_allowance") + @ExcludeMissing + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") + @ExcludeMissing + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) + + /** + * Credits granted per day. Lose-it-or-use-it; does not roll over. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** + * One or two event property values to evaluate matrix groups by + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") + + /** + * Per-dimension credit rates + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("daily_allowance") + @ExcludeMissing + fun _dailyAllowance(): JsonField = dailyAllowance + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + /** + * Returns the raw JSON value of [eventDayProperty]. + * + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_day_property") + @ExcludeMissing + fun _eventDayProperty(): JsonField = eventDayProperty + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowanceConfig]. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DailyCreditAllowanceConfig]. */ + class Builder internal constructor() { + + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } + + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) + + /** + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance + } + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** + * Sets [Builder.dimensions] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) + + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty + } + + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + private var validated: Boolean = false /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun validate(): MatrixValue = apply { + if (validated) { + return@apply } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + dimensionValues() + unitAmount() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, additionalProperties, ) } @@ -6261,7 +13498,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } /** @@ -6331,6 +13568,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -6380,11 +13627,10 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is DailyCreditAllowance && cadence == other.cadence && currency == other.currency && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -6398,6 +13644,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6406,7 +13653,7 @@ private constructor( Objects.hash( cadence, currency, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -6420,6 +13667,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6428,17 +13676,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, currency=$currency, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val currency: JsonField, private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -6452,6 +13699,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -6461,17 +13709,15 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -6511,14 +13757,17 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, currency, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -6531,6 +13780,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -6545,41 +13795,39 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * An ISO 4217 currency string for which this price is billed in. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun currency(): String = currency.getRequired("currency") /** - * An ISO 4217 currency string for which this price is billed in. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun currency(): String = currency.getRequired("currency") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for metered_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -6691,6 +13939,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -6711,17 +13967,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [currency]. * @@ -6740,6 +13985,17 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + /** * Returns the raw JSON value of [name]. * @@ -6851,6 +14107,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6876,32 +14142,28 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .currency() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -6919,36 +14181,33 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - currency = cumulativeGroupedAllocation.currency - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + currency = meteredAllowance.currency + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -6962,29 +14221,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** An ISO 4217 currency string for which this price is billed in. */ fun currency(currency: String) = currency(JsonField.of(currency)) @@ -7009,13 +14245,28 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + /** * 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("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -7365,6 +14616,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7407,30 +14679,27 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .currency() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("currency", currency), checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), modelType, checkRequired("name", name), billableMetricId, @@ -7443,6 +14712,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -7450,17 +14720,27 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() currency() itemId() + meteredAllowanceConfig().validate() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -7475,6 +14755,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -7496,12 +14777,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -7513,6 +14792,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -7635,6 +14915,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -7674,60 +14964,76 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), ) : this( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, mutableMapOf(), ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -7736,7 +15042,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -7745,24 +15051,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -7784,6 +15108,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -7800,12 +15144,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -7813,61 +15157,75 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) @@ -7882,7 +15240,9 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -7896,6 +15256,37 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -7919,41 +15310,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -7973,30 +15378,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -8004,7 +15415,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } /** @@ -8074,6 +15485,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -8123,12 +15544,11 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && currency == other.currency && itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -8141,6 +15561,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8148,9 +15569,9 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, currency, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -8163,6 +15584,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8171,7 +15593,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MeteredAllowance{cadence=$cadence, currency=$currency, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -8194,6 +15616,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8251,6 +15674,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8271,6 +15697,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8428,6 +15855,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -8587,6 +16022,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8651,6 +16096,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8672,6 +16118,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -9083,6 +16530,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9158,6 +16626,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9165,6 +16634,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -9190,6 +16669,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -9226,6 +16706,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -9348,6 +16829,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -9515,6 +17006,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -9628,6 +17129,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -9694,6 +17205,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -9716,6 +17228,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -9724,7 +17237,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -9747,6 +17260,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -9804,6 +17318,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -9824,6 +17341,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -9982,6 +17500,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10141,6 +17667,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10205,6 +17741,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10226,6 +17763,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -10637,6 +18175,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -10712,6 +18271,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -10719,6 +18279,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -10744,6 +18314,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -10780,6 +18351,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -10902,6 +18474,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -11177,6 +18759,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -11302,6 +18894,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -11368,6 +18970,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -11390,6 +18993,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -11398,7 +19002,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } @@ -11411,6 +19015,7 @@ private constructor( externalPriceId == other.externalPriceId && filter == other.filter && groupingKeys == other.groupingKeys && + metricParameterOverrides == other.metricParameterOverrides && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties @@ -11421,6 +19026,7 @@ private constructor( externalPriceId, filter, groupingKeys, + metricParameterOverrides, price, priceId, additionalProperties, @@ -11430,7 +19036,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, metricParameterOverrides=$metricParameterOverrides, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt index 0e4dddeb0..adbc2bd69 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateMultipleResponse.kt @@ -146,6 +146,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PriceEvaluateMultipleResponse = apply { if (validated) { return@apply @@ -476,6 +484,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply 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 138089286..aa989bf4c 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 @@ -105,6 +105,16 @@ private constructor( */ fun groupingKeys(): Optional> = body.groupingKeys() + /** + * Optional overrides for parameterized billable metric parameters. If the metric has parameter + * definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + body.metricParameterOverrides() + /** * Returns the raw JSON value of [timeframeEnd]. * @@ -148,6 +158,15 @@ private constructor( */ fun _groupingKeys(): JsonField> = body._groupingKeys() + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _metricParameterOverrides(): JsonField = + body._metricParameterOverrides() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -316,6 +335,32 @@ private constructor( */ fun addGroupingKey(groupingKey: String) = apply { body.addGroupingKey(groupingKey) } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = apply { + body.metricParameterOverrides(metricParameterOverrides) + } + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides(metricParameterOverrides: Optional) = + metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { body.metricParameterOverrides(metricParameterOverrides) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -476,6 +521,7 @@ private constructor( private val externalCustomerId: JsonField, private val filter: JsonField, private val groupingKeys: JsonField>, + private val metricParameterOverrides: JsonField, private val additionalProperties: MutableMap, ) { @@ -497,6 +543,9 @@ private constructor( @JsonProperty("grouping_keys") @ExcludeMissing groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), ) : this( timeframeEnd, timeframeStart, @@ -504,6 +553,7 @@ private constructor( externalCustomerId, filter, groupingKeys, + metricParameterOverrides, mutableMapOf(), ) @@ -559,6 +609,16 @@ private constructor( */ fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * Returns the raw JSON value of [timeframeEnd]. * @@ -615,6 +675,17 @@ private constructor( @ExcludeMissing fun _groupingKeys(): JsonField> = groupingKeys + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -650,6 +721,8 @@ private constructor( private var externalCustomerId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var groupingKeys: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -660,6 +733,7 @@ private constructor( externalCustomerId = body.externalCustomerId filter = body.filter groupingKeys = body.groupingKeys.map { it.toMutableList() } + metricParameterOverrides = body.metricParameterOverrides additionalProperties = body.additionalProperties.toMutableMap() } @@ -778,6 +852,32 @@ private constructor( } } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -818,12 +918,22 @@ private constructor( externalCustomerId, filter, (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -835,6 +945,7 @@ private constructor( externalCustomerId() filter() groupingKeys() + metricParameterOverrides().ifPresent { it.validate() } validated = true } @@ -859,7 +970,8 @@ private constructor( (if (customerId.asKnown().isPresent) 1 else 0) + (if (externalCustomerId.asKnown().isPresent) 1 else 0) + (if (filter.asKnown().isPresent) 1 else 0) + - (groupingKeys.asKnown().getOrNull()?.size ?: 0) + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -873,6 +985,7 @@ private constructor( externalCustomerId == other.externalCustomerId && filter == other.filter && groupingKeys == other.groupingKeys && + metricParameterOverrides == other.metricParameterOverrides && additionalProperties == other.additionalProperties } @@ -884,6 +997,7 @@ private constructor( externalCustomerId, filter, groupingKeys, + metricParameterOverrides, additionalProperties, ) } @@ -891,7 +1005,124 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, customerId=$customerId, externalCustomerId=$externalCustomerId, filter=$filter, groupingKeys=$groupingKeys, additionalProperties=$additionalProperties}" + "Body{timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, customerId=$customerId, externalCustomerId=$externalCustomerId, filter=$filter, groupingKeys=$groupingKeys, metricParameterOverrides=$metricParameterOverrides, additionalProperties=$additionalProperties}" + } + + /** + * Optional overrides for parameterized billable metric parameters. If the metric has parameter + * definitions and no overrides are provided, defaults will be used. + */ + class MetricParameterOverrides + @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 [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt index 21999d6ba..c49317d25 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParams.kt @@ -822,6 +822,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1189,6 +1198,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Event = apply { if (validated) { return@apply @@ -1289,6 +1307,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Properties = apply { if (validated) { return@apply @@ -1367,6 +1395,7 @@ private constructor( private val externalPriceId: JsonField, private val filter: JsonField, private val groupingKeys: JsonField>, + private val metricParameterOverrides: JsonField, private val price: JsonField, private val priceId: JsonField, private val additionalProperties: MutableMap, @@ -1381,9 +1410,20 @@ private constructor( @JsonProperty("grouping_keys") @ExcludeMissing groupingKeys: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, filter, groupingKeys, price, priceId, mutableMapOf()) + ) : this( + externalPriceId, + filter, + groupingKeys, + metricParameterOverrides, + price, + priceId, + mutableMapOf(), + ) /** * The external ID of a price to evaluate that exists in your Orb account. @@ -1412,6 +1452,16 @@ private constructor( */ fun groupingKeys(): Optional> = groupingKeys.getOptional("grouping_keys") + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * New floating price request body params. * @@ -1455,6 +1505,17 @@ private constructor( @ExcludeMissing fun _groupingKeys(): JsonField> = groupingKeys + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [price]. * @@ -1493,6 +1554,8 @@ private constructor( private var externalPriceId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var groupingKeys: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1502,6 +1565,7 @@ private constructor( externalPriceId = priceEvaluation.externalPriceId filter = priceEvaluation.filter groupingKeys = priceEvaluation.groupingKeys.map { it.toMutableList() } + metricParameterOverrides = priceEvaluation.metricParameterOverrides price = priceEvaluation.price priceId = priceEvaluation.priceId additionalProperties = priceEvaluation.additionalProperties.toMutableMap() @@ -1574,6 +1638,32 @@ private constructor( } } + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** New floating price request body params. */ fun price(price: Price?) = price(JsonField.ofNullable(price)) @@ -1650,6 +1740,13 @@ private constructor( fun price(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -1739,6 +1836,16 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: NewFloatingMinimumCompositePrice) = price(Price.ofMinimumComposite(minimumComposite)) @@ -1793,6 +1900,7 @@ private constructor( externalPriceId, filter, (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, price, priceId, additionalProperties.toMutableMap(), @@ -1801,6 +1909,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): PriceEvaluation = apply { if (validated) { return@apply @@ -1809,6 +1926,7 @@ private constructor( externalPriceId() filter() groupingKeys() + metricParameterOverrides().ifPresent { it.validate() } price().ifPresent { it.validate() } priceId() validated = true @@ -1833,9 +1951,133 @@ private constructor( (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (filter.asKnown().isPresent) 1 else 0) + (groupingKeys.asKnown().getOrNull()?.size ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + /** + * Optional overrides for parameterized billable metric parameters. If the metric has + * parameter definitions and no overrides are provided, defaults will be used. + */ + class MetricParameterOverrides + @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 + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -1855,6 +2097,7 @@ private constructor( private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, private val unitWithPercent: NewFloatingUnitWithPercentPrice? = null, private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, private val tieredWithProration: NewFloatingTieredWithProrationPrice? = null, private val unitWithProration: NewFloatingUnitWithProrationPrice? = null, private val groupedAllocation: NewFloatingGroupedAllocationPrice? = null, @@ -1875,6 +2118,8 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, private val minimumComposite: NewFloatingMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -1917,6 +2162,9 @@ private constructor( fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -1961,6 +2209,12 @@ private constructor( fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) @@ -1996,6 +2250,8 @@ private constructor( fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null @@ -2025,6 +2281,10 @@ private constructor( fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + fun isMinimumComposite(): Boolean = minimumComposite != null fun isPercent(): Boolean = percent != null @@ -2067,6 +2327,9 @@ private constructor( fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + fun asTieredWithProration(): NewFloatingTieredWithProrationPrice = tieredWithProration.getOrThrow("tieredWithProration") @@ -2110,6 +2373,12 @@ private constructor( fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + fun asMinimumComposite(): NewFloatingMinimumCompositePrice = minimumComposite.getOrThrow("minimumComposite") @@ -2119,6 +2388,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewFloatingUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) @@ -2139,6 +2438,8 @@ private constructor( unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) @@ -2166,6 +2467,9 @@ private constructor( visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) cumulativeGroupedAllocation != null -> visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -2174,6 +2478,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Price = apply { if (validated) { return@apply @@ -2253,6 +2567,12 @@ private constructor( matrixWithAllocation.validate() } + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) { @@ -2339,6 +2659,16 @@ private constructor( cumulativeGroupedAllocation.validate() } + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + override fun visitMinimumComposite( minimumComposite: NewFloatingMinimumCompositePrice ) { @@ -2421,6 +2751,10 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ) = matrixWithAllocation.validity() + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = tieredWithProration.validity() @@ -2479,6 +2813,13 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + override fun visitMinimumComposite( minimumComposite: NewFloatingMinimumCompositePrice ) = minimumComposite.validity() @@ -2512,6 +2853,7 @@ private constructor( packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && @@ -2526,6 +2868,8 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && minimumComposite == other.minimumComposite && percent == other.percent && eventOutput == other.eventOutput @@ -2547,6 +2891,7 @@ private constructor( packageWithAllocation, unitWithPercent, matrixWithAllocation, + matrixWithThresholdDiscounts, tieredWithProration, unitWithProration, groupedAllocation, @@ -2561,6 +2906,8 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, minimumComposite, percent, eventOutput, @@ -2586,6 +2933,8 @@ private constructor( unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" @@ -2610,6 +2959,9 @@ private constructor( "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -2670,6 +3022,11 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ) = Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + @JvmStatic fun ofTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice @@ -2737,6 +3094,14 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + @JvmStatic fun ofMinimumComposite(minimumComposite: NewFloatingMinimumCompositePrice) = Price(minimumComposite = minimumComposite) @@ -2788,6 +3153,10 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ): T + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ): T @@ -2838,6 +3207,10 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + fun visitMinimumComposite(minimumComposite: NewFloatingMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -2956,6 +3329,14 @@ private constructor( ?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } "tiered_with_proration" -> { return tryDeserialize( node, @@ -3070,6 +3451,16 @@ private constructor( ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } ?: Price(_json = json) } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } "minimum_composite" -> { return tryDeserialize( node, @@ -3123,6 +3514,8 @@ private constructor( generator.writeObject(value.unitWithPercent) value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> @@ -3151,6 +3544,10 @@ private constructor( generator.writeObject(value.cumulativeGroupedBulk) value.cumulativeGroupedAllocation != null -> generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) value.minimumComposite != null -> generator.writeObject(value.minimumComposite) value.percent != null -> generator.writeObject(value.percent) @@ -3181,6 +3578,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -3238,6 +3636,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -3258,6 +3659,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -3416,6 +3818,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -3576,6 +3986,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -3640,6 +4060,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3662,6 +4083,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -4073,6 +4495,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -4148,6 +4591,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -4155,6 +4599,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): BulkWithFilters = apply { if (validated) { return@apply @@ -4180,6 +4634,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -4216,6 +4671,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -4417,6 +4873,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply @@ -4620,6 +5086,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -4849,6 +5325,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -5040,6 +5526,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -5146,9 +5642,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply } validated = true @@ -5212,6 +5718,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -5234,6 +5741,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -5242,17 +5750,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class MatrixWithThresholdDiscounts @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -5266,6 +5774,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -5278,14 +5787,14 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -5325,14 +5834,17 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, currency, - groupedWithMinMaxThresholdsConfig, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, billableMetricId, @@ -5345,6 +5857,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -5368,32 +5881,32 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for matrix_with_threshold_discounts pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -5505,6 +6018,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5535,17 +6056,6 @@ private constructor( @ExcludeMissing fun _currency(): JsonField = currency - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -5554,6 +6064,18 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig + /** * Returns the raw JSON value of [name]. * @@ -5665,6 +6187,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5691,31 +6223,31 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [MatrixWithThresholdDiscounts]. * * The following fields are required: * ```java * .cadence() * .currency() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [MatrixWithThresholdDiscounts]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + JsonValue.from("matrix_with_threshold_discounts") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -5733,35 +6265,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = apply { - cadence = groupedWithMinMaxThresholds.cadence - currency = groupedWithMinMaxThresholds.currency - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = matrixWithThresholdDiscounts.cadence + currency = matrixWithThresholdDiscounts.currency + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -5788,29 +6322,6 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -5823,13 +6334,36 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -6179,6 +6713,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -6221,7 +6776,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6229,22 +6784,22 @@ private constructor( * ```java * .cadence() * .currency() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( checkRequired("cadence", cadence), checkRequired("currency", currency), + checkRequired("itemId", itemId), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, ), - checkRequired("itemId", itemId), modelType, checkRequired("name", name), billableMetricId, @@ -6257,6 +6812,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -6264,17 +6820,27 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { if (validated) { return@apply } cadence().validate() currency() - groupedWithMinMaxThresholdsConfig().validate() itemId() + matrixWithThresholdDiscountsConfig().validate() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -6289,6 +6855,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -6311,10 +6878,11 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -6327,6 +6895,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -6449,6 +7018,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -6488,108 +7067,140 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Unit price used for usage that does not match any defined matrix cell. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The maximum amount to charge each group + * First matrix dimension key. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") /** - * The minimum amount to charge each group, regardless of usage + * Per-cell unit prices. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") /** - * The base price charged per group + * Optional second matrix dimension key. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") /** - * Returns the raw JSON value of [groupingKey]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [firstDimension]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [firstDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("first_dimension") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _firstDimension(): JsonField = firstDimension /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("matrix_values") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _matrixValues(): JsonField> = matrixValues /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [secondDimension]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [secondDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("second_dimension") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -6607,203 +7218,6848 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [MatrixWithThresholdDiscountsConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties + matrixWithThresholdDiscountsConfig.additionalProperties .toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** + * Unit price used for usage that does not match any defined matrix cell. + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.firstDimension] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.firstDimension] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + currency = groupedWithMinMaxThresholds.currency + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. * * You should usually call [Builder.minimumCharge] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + currency == other.currency && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("cumulative_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) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class DailyCreditAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val dailyCreditAllowanceConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + dailyCreditAllowanceConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + dailyCreditAllowanceConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for daily_credit_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. + * + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DailyCreditAllowance]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var dailyCreditAllowanceConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + currency = dailyCreditAllowance.currency + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) + + /** + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowance = + DailyCreditAllowance( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + dailyCreditAllowanceConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("daily_credit_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("daily_allowance") + @ExcludeMissing + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") + @ExcludeMissing + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) + + /** + * Credits granted per day. Lose-it-or-use-it; does not roll over. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** + * One or two event property values to evaluate matrix groups by + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") + + /** + * Per-dimension credit rates + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("daily_allowance") + @ExcludeMissing + fun _dailyAllowance(): JsonField = dailyAllowance + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + /** + * Returns the raw JSON value of [eventDayProperty]. + * + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_day_property") + @ExcludeMissing + fun _eventDayProperty(): JsonField = eventDayProperty + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowanceConfig]. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DailyCreditAllowanceConfig]. */ + class Builder internal constructor() { + + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } + + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) + + /** + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance + } + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** + * Sets [Builder.dimensions] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) + + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty + } + + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + private var validated: Boolean = false /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun validate(): MatrixValue = apply { + if (validated) { + return@apply } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + dimensionValues() + unitAmount() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, additionalProperties, ) } @@ -6811,7 +14067,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } /** @@ -6881,6 +14137,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -6930,11 +14196,10 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is DailyCreditAllowance && cadence == other.cadence && currency == other.currency && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -6948,6 +14213,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6956,7 +14222,7 @@ private constructor( Objects.hash( cadence, currency, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -6970,6 +14236,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6978,17 +14245,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, currency=$currency, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val currency: JsonField, private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -7002,6 +14268,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -7011,17 +14278,15 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -7061,14 +14326,17 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, currency, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -7081,6 +14349,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -7095,41 +14364,39 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * An ISO 4217 currency string for which this price is billed in. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun currency(): String = currency.getRequired("currency") /** - * An ISO 4217 currency string for which this price is billed in. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun currency(): String = currency.getRequired("currency") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for metered_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7241,6 +14508,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7261,17 +14536,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [currency]. * @@ -7290,6 +14554,17 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + /** * Returns the raw JSON value of [name]. * @@ -7401,6 +14676,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7426,32 +14711,28 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .currency() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7469,36 +14750,33 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - currency = cumulativeGroupedAllocation.currency - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + currency = meteredAllowance.currency + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -7512,29 +14790,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** An ISO 4217 currency string for which this price is billed in. */ fun currency(currency: String) = currency(JsonField.of(currency)) @@ -7559,13 +14814,28 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + /** * 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("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -7915,6 +15185,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7957,30 +15248,27 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .currency() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("currency", currency), checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), modelType, checkRequired("name", name), billableMetricId, @@ -7993,6 +15281,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -8000,17 +15289,27 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() currency() itemId() + meteredAllowanceConfig().validate() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -8025,6 +15324,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -8046,12 +15346,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -8063,6 +15361,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8185,6 +15484,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -8224,60 +15533,76 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), ) : this( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, mutableMapOf(), ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -8286,7 +15611,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -8295,24 +15620,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -8334,6 +15677,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -8350,12 +15713,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -8363,61 +15726,75 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) @@ -8432,7 +15809,9 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -8446,6 +15825,37 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8469,41 +15879,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -8523,30 +15947,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -8554,7 +15984,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } /** @@ -8624,6 +16054,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -8673,12 +16113,11 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && currency == other.currency && itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -8691,6 +16130,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8698,9 +16138,9 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, currency, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -8713,6 +16153,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8721,7 +16162,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MeteredAllowance{cadence=$cadence, currency=$currency, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -8744,6 +16185,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8801,6 +16243,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8821,6 +16266,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8978,6 +16424,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9137,6 +16591,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9201,6 +16665,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9222,6 +16687,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -9633,6 +17099,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9708,6 +17195,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9715,6 +17203,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -9740,6 +17238,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -9776,6 +17275,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -9898,6 +17398,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -10065,6 +17575,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -10178,6 +17698,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -10244,6 +17774,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -10266,6 +17797,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -10274,7 +17806,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -10297,6 +17829,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -10354,6 +17887,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10374,6 +17910,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -10532,6 +18069,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10691,6 +18236,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10755,6 +18310,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10776,6 +18332,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -11187,6 +18744,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11262,6 +18840,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -11269,6 +18848,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -11294,6 +18883,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -11330,6 +18920,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -11452,6 +19043,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -11727,6 +19328,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -11852,6 +19463,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -11918,6 +19539,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -11940,6 +19562,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -11948,7 +19571,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } @@ -11961,6 +19584,7 @@ private constructor( externalPriceId == other.externalPriceId && filter == other.filter && groupingKeys == other.groupingKeys && + metricParameterOverrides == other.metricParameterOverrides && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties @@ -11971,6 +19595,7 @@ private constructor( externalPriceId, filter, groupingKeys, + metricParameterOverrides, price, priceId, additionalProperties, @@ -11980,7 +19605,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "PriceEvaluation{externalPriceId=$externalPriceId, filter=$filter, groupingKeys=$groupingKeys, metricParameterOverrides=$metricParameterOverrides, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt index 5f3e5d70b..4c405ff02 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsResponse.kt @@ -148,6 +148,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PriceEvaluatePreviewEventsResponse = apply { if (validated) { return@apply @@ -478,6 +486,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt index 5da610808..c4d157778 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt @@ -147,6 +147,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PriceEvaluateResponse = apply { if (validated) { return@apply 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 db048139e..df789d911 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 @@ -378,6 +378,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -485,6 +494,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt index 370d06454..09f986cfd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceInterval.kt @@ -38,6 +38,7 @@ private constructor( private val price: JsonField, private val startDate: JsonField, private val usageCustomerIds: JsonField>, + private val metricParameterOverrides: JsonField, private val additionalProperties: MutableMap, ) { @@ -70,6 +71,9 @@ private constructor( @JsonProperty("usage_customer_ids") @ExcludeMissing usageCustomerIds: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), ) : this( id, billingCycleDay, @@ -82,6 +86,7 @@ private constructor( price, startDate, usageCustomerIds, + metricParameterOverrides, mutableMapOf(), ) @@ -192,6 +197,16 @@ private constructor( fun usageCustomerIds(): Optional> = usageCustomerIds.getOptional("usage_customer_ids") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, values + * are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server + * responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * Returns the raw JSON value of [id]. * @@ -288,6 +303,16 @@ private constructor( @ExcludeMissing fun _usageCustomerIds(): JsonField> = usageCustomerIds + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = metricParameterOverrides + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -339,6 +364,7 @@ private constructor( private var price: JsonField? = null private var startDate: JsonField? = null private var usageCustomerIds: JsonField>? = null + private var metricParameterOverrides: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -355,6 +381,7 @@ private constructor( price = priceInterval.price startDate = priceInterval.startDate usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } + metricParameterOverrides = priceInterval.metricParameterOverrides additionalProperties = priceInterval.additionalProperties.toMutableMap() } @@ -605,6 +632,13 @@ private constructor( fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) @@ -685,6 +719,14 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: Price.MinimumComposite) = price(Price.ofMinimumComposite(minimumComposite)) @@ -744,6 +786,31 @@ private constructor( } } + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides(metricParameterOverrides: Optional) = + metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -800,12 +867,21 @@ private constructor( checkRequired("price", price), checkRequired("startDate", startDate), checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, + metricParameterOverrides, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PriceInterval = apply { if (validated) { return@apply @@ -822,6 +898,7 @@ private constructor( price().validate() startDate() usageCustomerIds() + metricParameterOverrides().ifPresent { it.validate() } validated = true } @@ -851,7 +928,125 @@ private constructor( ?: 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (startDate.asKnown().isPresent) 1 else 0) + - (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Override values for parameterized billable metric variables. Keys are parameter names, values + * are the override values. + */ + class MetricParameterOverrides + @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 [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -870,6 +1065,7 @@ private constructor( price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && + metricParameterOverrides == other.metricParameterOverrides && additionalProperties == other.additionalProperties } @@ -886,6 +1082,7 @@ private constructor( price, startDate, usageCustomerIds, + metricParameterOverrides, additionalProperties, ) } @@ -893,5 +1090,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, metricParameterOverrides=$metricParameterOverrides, additionalProperties=$additionalProperties}" } 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 619665569..0365d0aab 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 @@ -189,6 +189,13 @@ private constructor( fun addData(matrixWithAllocation: Price.MatrixWithAllocation) = addData(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [addData] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun addData(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + addData(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** Alias for calling [addData] with `Price.ofTieredWithProration(tieredWithProration)`. */ fun addData(tieredWithProration: Price.TieredWithProration) = addData(Price.ofTieredWithProration(tieredWithProration)) @@ -271,6 +278,16 @@ private constructor( fun addData(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = addData(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [addData] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun addData(dailyCreditAllowance: Price.DailyCreditAllowance) = + addData(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [addData] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun addData(meteredAllowance: Price.MeteredAllowance) = + addData(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [addData] with `Price.ofMinimumComposite(minimumComposite)`. */ fun addData(minimumComposite: Price.MinimumComposite) = addData(Price.ofMinimumComposite(minimumComposite)) @@ -337,6 +354,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): PriceListPageResponse = apply { if (validated) { return@apply 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 c2f697bd6..f76f2d64d 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 @@ -370,6 +370,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -477,6 +486,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt index dbbebab2f..fac5e5c08 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGrouping.kt @@ -165,6 +165,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubLineItemGrouping = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt index 7051e20f2..37f4e9f11 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemMatrixConfig.kt @@ -153,6 +153,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubLineItemMatrixConfig = apply { if (validated) { return@apply 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 f02d6edea..de21a26fd 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 @@ -1484,6 +1484,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Subscription = apply { if (validated) { return@apply @@ -1592,6 +1600,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = discountInterval.accept(new DiscountInterval.Visitor>() { + * @Override + * public Optional visitAmount(AmountDiscountInterval amount) { + * return Optional.of(amount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { amount != null -> visitor.visitAmount(amount) @@ -1602,6 +1639,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountInterval = apply { if (validated) { return@apply @@ -1825,6 +1871,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -1958,6 +2013,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply 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 a869a43e1..260a50366 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 @@ -646,6 +646,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -800,6 +809,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): CancelOption = apply { if (validated) { return@apply 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 050ba091a..c07001dcd 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 @@ -836,6 +836,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply 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 3f28fc4b0..f0dcaf826 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 @@ -553,6 +553,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionChangeApplyResponse = apply { if (validated) { return@apply @@ -691,6 +699,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply 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 6e7c1e186..fb3eedaaa 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 @@ -553,6 +553,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionChangeCancelResponse = apply { if (validated) { return@apply @@ -691,6 +699,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListPageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListPageResponse.kt index 7c8465146..b79c9fdb7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListPageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListPageResponse.kt @@ -192,6 +192,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionChangeListPageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListParams.kt index 046066def..941e3e34a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListParams.kt @@ -347,6 +347,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListResponse.kt index a9a7126a5..b2cb807c7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeListResponse.kt @@ -328,6 +328,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionChangeListResponse = apply { if (validated) { return@apply @@ -456,6 +464,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt index 1474cc61c..43dbe1646 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionChangeMinified.kt @@ -124,6 +124,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionChangeMinified = apply { if (validated) { return@apply 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 e90fbdbee..3feb5fde9 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 @@ -553,6 +553,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionChangeRetrieveResponse = apply { if (validated) { return@apply @@ -691,6 +699,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply 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 bcb06988b..f2ee3908f 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 @@ -3613,6 +3613,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -4146,6 +4155,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AddAdjustment = apply { if (validated) { return@apply @@ -4226,6 +4244,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentageDiscount != null -> @@ -4239,6 +4287,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -4477,6 +4535,7 @@ private constructor( private val endDate: JsonField, private val externalPriceId: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, @@ -4502,6 +4561,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -4519,6 +4581,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -4572,6 +4635,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -4665,6 +4738,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -4735,6 +4819,8 @@ private constructor( private var endDate: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() @@ -4749,6 +4835,7 @@ private constructor( endDate = addPrice.endDate externalPriceId = addPrice.externalPriceId maximumAmount = addPrice.maximumAmount + metricParameterOverrides = addPrice.metricParameterOverrides minimumAmount = addPrice.minimumAmount planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price @@ -4876,6 +4963,32 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -5003,6 +5116,13 @@ private constructor( fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -5092,6 +5212,16 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: NewSubscriptionMinimumCompositePrice) = price(Price.ofMinimumComposite(minimumComposite)) @@ -5169,6 +5299,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -5180,6 +5311,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AddPrice = apply { if (validated) { return@apply @@ -5190,6 +5330,7 @@ private constructor( endDate() externalPriceId() maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } minimumAmount() planPhaseOrder() price().ifPresent { it.validate() } @@ -5219,12 +5360,136 @@ private constructor( (if (endDate.asKnown().isPresent) 1 else 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @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 + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -5245,6 +5510,7 @@ private constructor( private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, private val tieredWithProration: TieredWithProration? = null, private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, @@ -5266,6 +5532,8 @@ private constructor( null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, private val minimumComposite: NewSubscriptionMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -5308,6 +5576,9 @@ private constructor( fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -5354,6 +5625,12 @@ private constructor( fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) @@ -5389,6 +5666,8 @@ private constructor( fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null @@ -5418,6 +5697,10 @@ private constructor( fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + fun isMinimumComposite(): Boolean = minimumComposite != null fun isPercent(): Boolean = percent != null @@ -5460,6 +5743,9 @@ private constructor( fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") @@ -5504,6 +5790,12 @@ private constructor( fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + fun asMinimumComposite(): NewSubscriptionMinimumCompositePrice = minimumComposite.getOrThrow("minimumComposite") @@ -5513,6 +5805,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewSubscriptionUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) @@ -5533,6 +5855,8 @@ private constructor( unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) @@ -5560,6 +5884,9 @@ private constructor( visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) cumulativeGroupedAllocation != null -> visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -5568,6 +5895,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Price = apply { if (validated) { return@apply @@ -5647,6 +5984,12 @@ private constructor( matrixWithAllocation.validate() } + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) { @@ -5734,6 +6077,16 @@ private constructor( cumulativeGroupedAllocation.validate() } + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + override fun visitMinimumComposite( minimumComposite: NewSubscriptionMinimumCompositePrice ) { @@ -5818,6 +6171,10 @@ private constructor( matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice ) = matrixWithAllocation.validity() + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) = tieredWithProration.validity() @@ -5877,6 +6234,13 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + override fun visitMinimumComposite( minimumComposite: NewSubscriptionMinimumCompositePrice ) = minimumComposite.validity() @@ -5910,6 +6274,7 @@ private constructor( packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && @@ -5924,6 +6289,8 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && minimumComposite == other.minimumComposite && percent == other.percent && eventOutput == other.eventOutput @@ -5945,6 +6312,7 @@ private constructor( packageWithAllocation, unitWithPercent, matrixWithAllocation, + matrixWithThresholdDiscounts, tieredWithProration, unitWithProration, groupedAllocation, @@ -5959,6 +6327,8 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, minimumComposite, percent, eventOutput, @@ -5984,6 +6354,8 @@ private constructor( unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" @@ -6008,6 +6380,9 @@ private constructor( "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -6068,6 +6443,11 @@ private constructor( matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice ) = Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + @JvmStatic fun ofTieredWithProration(tieredWithProration: TieredWithProration) = Price(tieredWithProration = tieredWithProration) @@ -6135,6 +6515,14 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + @JvmStatic fun ofMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice) = Price(minimumComposite = minimumComposite) @@ -6188,6 +6576,10 @@ private constructor( matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice ): T + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T fun visitUnitWithProration( @@ -6243,6 +6635,10 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + fun visitMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -6370,6 +6766,14 @@ private constructor( ?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } "tiered_with_proration" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tieredWithProration = it, _json = json) } @@ -6483,6 +6887,16 @@ private constructor( ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } ?: Price(_json = json) } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } "minimum_composite" -> { return tryDeserialize( node, @@ -6536,6 +6950,8 @@ private constructor( generator.writeObject(value.unitWithPercent) value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> @@ -6564,6 +6980,10 @@ private constructor( generator.writeObject(value.cumulativeGroupedBulk) value.cumulativeGroupedAllocation != null -> generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) value.minimumComposite != null -> generator.writeObject(value.minimumComposite) value.percent != null -> generator.writeObject(value.percent) @@ -6594,6 +7014,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -6652,6 +7073,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6675,6 +7099,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -6834,6 +7259,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7003,6 +7436,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7076,6 +7519,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7099,6 +7543,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -7517,6 +7962,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7613,6 +8079,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -7621,6 +8088,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): BulkWithFilters = apply { if (validated) { return@apply @@ -7646,6 +8123,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -7683,6 +8161,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -7885,6 +8364,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply @@ -8088,6 +8577,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -8317,6 +8816,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -8508,6 +9017,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -8614,6 +9133,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -8680,6 +9209,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8703,6 +9233,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8712,17 +9243,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class MatrixWithThresholdDiscounts @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -8735,6 +9267,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8748,16 +9281,17 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -8794,6 +9328,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8803,9 +9340,9 @@ private constructor( ) : this( cadence, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -8817,6 +9354,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -8840,12 +9378,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * Configuration for matrix_with_threshold_discounts pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -8862,16 +9412,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -8976,6 +9516,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -9014,23 +9562,24 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig /** - * Returns the raw JSON value of [tieredWithProrationConfig]. + * Returns the raw JSON value of [name]. * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [billableMetricId]. @@ -9145,6 +9694,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9181,28 +9740,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [MatrixWithThresholdDiscounts]. * * The following fields are required: * ```java * .cadence() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [MatrixWithThresholdDiscounts]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = + private var matrixWithThresholdDiscountsConfig: + JsonField? = null + private var modelType: JsonValue = + JsonValue.from("matrix_with_threshold_discounts") + private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -9220,35 +9781,40 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = + apply { + cadence = matrixWithThresholdDiscounts.cadence + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance + billingCycleConfiguration = + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + currency = matrixWithThresholdDiscounts.currency + dimensionalPriceConfiguration = + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata + referenceId = matrixWithThresholdDiscounts.referenceId + additionalProperties = + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9274,13 +9840,36 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9300,22 +9889,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9664,6 +10237,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9728,7 +10322,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -9736,19 +10330,22 @@ private constructor( * ```java * .cadence() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired( + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, + ), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -9760,6 +10357,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9768,20 +10366,30 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { if (validated) { return@apply } cadence().validate() itemId() + matrixWithThresholdDiscountsConfig().validate() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -9793,6 +10401,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -9816,11 +10425,12 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -9832,6 +10442,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -9955,6 +10566,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -9994,40 +10615,140 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("default_unit_amount") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * Unit price used for usage that does not match any defined matrix cell. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * Returns the raw JSON value of [tiers]. + * First matrix dimension key. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Per-cell unit prices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Optional second matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -10045,58 +10766,165 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [MatrixWithThresholdDiscountsConfig]. * * The following fields are required: * ```java - * .tiers() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = apply { + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } + additionalProperties = + matrixWithThresholdDiscountsConfig.additionalProperties + .toMutableMap() + } /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Unit price used for usage that does not match any defined matrix cell. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. * * @throws IllegalStateException if the field was previously set to a * non-list. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) } } @@ -10123,32 +10951,56 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } validated = true } @@ -10168,40 +11020,51 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tierLowerBound: JsonField, + private val firstDimensionValue: JsonField, private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tier_lower_bound") + @JsonProperty("first_dimension_value") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), + firstDimensionValue: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + mutableMapOf(), + ) /** - * Inclusive tier starting value - * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") /** - * Amount per unit - * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). @@ -10209,14 +11072,21 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [tierLowerBound]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("first_dimension_value") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _firstDimensionValue(): JsonField = firstDimensionValue /** * Returns the raw JSON value of [unitAmount]. @@ -10228,6 +11098,16 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -10243,48 +11123,51 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tier]. + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. * * The following fields are required: * ```java - * .tierLowerBound() + * .firstDimensionValue() * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Tier]. */ + /** A builder for [MatrixValue]. */ class Builder internal constructor() { - private var tierLowerBound: JsonField? = null + private var firstDimensionValue: JsonField? = null private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } - /** Amount per unit */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) @@ -10299,6 +11182,28 @@ private constructor( this.unitAmount = unitAmount } + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10322,36 +11227,48 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [MatrixValue]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```java - * .tierLowerBound() + * .firstDimensionValue() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), checkRequired("unitAmount", unitAmount), + secondDimensionValue, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Tier = apply { + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { if (validated) { return@apply } - tierLowerBound() + firstDimensionValue() unitAmount() + secondDimensionValue() validated = true } @@ -10371,28 +11288,470 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Tier && - tierLowerBound == other.tierLowerBound && + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -10400,17 +11759,30 @@ private constructor( return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" } /** @@ -10480,6 +11852,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -10529,12 +11911,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is MatrixWithThresholdDiscounts && cadence == other.cadence && itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -10546,6 +11929,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -10555,9 +11939,9 @@ private constructor( Objects.hash( cadence, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10569,6 +11953,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -10578,18 +11963,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MatrixWithThresholdDiscounts{cadence=$cadence, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class TieredWithProration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -10602,6 +11986,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10612,11 +11997,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -10626,6 +12006,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -10662,6 +12046,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10670,10 +12057,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10685,6 +12072,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10699,18 +12087,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -10725,7 +12101,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10742,6 +12118,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -10846,6 +12232,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10875,17 +12269,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -10902,6 +12285,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -11015,6 +12409,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -11051,30 +12455,28 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [TieredWithProration]. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -11092,38 +12494,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -11137,29 +12538,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -11178,7 +12556,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -11198,6 +12576,22 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11546,6 +12940,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11610,30 +13025,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11645,6 +13057,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -11653,20 +13066,30 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -11678,6 +13101,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -11700,12 +13124,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -11717,6 +13141,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -11840,6 +13265,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -11879,108 +13314,40 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + @JsonProperty("tiers") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") - - /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - - /** - * The minimum amount to charge each group, regardless of usage - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * The base price charged per group + * Tiers for rating based on total usage quantities into the specified tier with + * proration * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey - - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [tiers]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("tiers") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _tiers(): JsonField> = tiers @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -11998,100 +13365,59 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [TieredWithProrationConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .tiers() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Tiers for rating based on total usage quantities into the specified tier + * with proration */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.tiers] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) - /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Adds a single [Tier] to [tiers]. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -12117,41 +13443,42 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + tiers().forEach { it.validate() } validated = true } @@ -12171,38 +13498,259 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is TieredWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) - } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -12272,6 +13820,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -12321,13 +13879,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is TieredWithProration && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -12339,6 +13896,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -12347,10 +13905,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -12362,6 +13920,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -12371,15 +13930,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -12395,6 +13954,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12405,10 +13965,10 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = + groupedWithMinMaxThresholdsConfig: + JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -12455,6 +14015,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12463,7 +14026,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -12478,6 +14041,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12493,15 +14057,15 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * Configuration for grouped_with_min_max_thresholds pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" ) /** @@ -12518,7 +14082,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12639,6 +14203,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12669,15 +14241,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON * field has an unexpected type. */ - @JsonProperty("cumulative_grouped_allocation_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig /** * Returns the raw JSON value of [itemId]. @@ -12808,6 +14380,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12844,12 +14426,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() * ``` @@ -12857,16 +14439,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = + private var groupedWithMinMaxThresholdsConfig: + JsonField? = null private var itemId: JsonField? = null private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -12885,37 +14467,39 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -12930,27 +14514,27 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) ) /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } /** The id of the item the price will be associated with. */ @@ -12971,7 +14555,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -13339,6 +14923,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13403,26 +15008,26 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, ), checkRequired("itemId", itemId), modelType, @@ -13438,6 +15043,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13446,16 +15052,26 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -13471,6 +15087,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13493,10 +15110,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -13510,6 +15127,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -13633,6 +15251,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -13672,115 +15300,108 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, private val groupingKey: JsonField, - private val unitAmount: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") - @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") - @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + @JsonProperty("maximum_charge") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - mutableMapOf(), - ) + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * The overall allocation across all groups + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The allocation per individual group + * The maximum amount to charge each group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") /** - * The event property used to group usage before applying allocations + * The minimum amount to charge each group, regardless of usage * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") /** - * The amount to charge for each unit outside of the allocation + * The base price charged per group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("grouping_key") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [maximumCharge]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("maximum_charge") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _maximumCharge(): JsonField = maximumCharge /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [minimumCharge]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("minimum_charge") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _minimumCharge(): JsonField = minimumCharge /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [perUnitRate]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_amount") + @JsonProperty("per_unit_rate") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _perUnitRate(): JsonField = perUnitRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -13798,100 +15419,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() * .groupingKey() - * .unitAmount() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null private var groupingKey: JsonField? = null - private var unitAmount: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties + groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed + * You should usually call [Builder.maximumCharge] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge } - /** The event property used to group usage before applying allocations */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.minimumCharge] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge } - /** The amount to charge for each unit outside of the allocation */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.perUnitRate] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed [String] + * You should usually call [Builder.perUnitRate] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate } fun additionalProperties(additionalProperties: Map) = @@ -13917,41 +15538,51 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() * .groupingKey() - * .unitAmount() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( checkRequired("groupingKey", groupingKey), - checkRequired("unitAmount", unitAmount), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() groupingKey() - unitAmount() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -13971,30 +15602,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is GroupedWithMinMaxThresholdsConfig && groupingKey == other.groupingKey && - unitAmount == other.unitAmount && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, groupingKey, - unitAmount, + maximumCharge, + minimumCharge, + perUnitRate, additionalProperties, ) } @@ -14002,7 +15633,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -14072,6 +15703,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -14121,10 +15762,10 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -14139,6 +15780,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -14147,7 +15789,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -14162,6 +15804,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -14171,17 +15814,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class Percent + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -14194,6 +15838,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -14204,6 +15849,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -14213,9 +15863,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -14252,6 +15899,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -14260,10 +15910,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14275,6 +15925,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -14289,6 +15940,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -14303,7 +15966,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -14320,15 +15983,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -14433,6 +16087,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -14462,6 +16124,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -14478,16 +16151,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -14601,6 +16264,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -14636,27 +16309,31 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -14674,32 +16351,40 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -14713,6 +16398,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -14731,7 +16439,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -14751,21 +16459,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -15114,6 +16807,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -15178,27 +16892,30 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -15210,6 +16927,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -15218,20 +16936,30 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -15243,6 +16971,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -15265,10 +16994,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + - (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -15280,6 +17011,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -15403,6 +17135,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -15442,39 +17184,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("cumulative_allocation") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * What percent of the component subtotals to charge + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun percent(): Double = percent.getRequired("percent") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [percent]. + * The allocation per individual group * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("group_allocation") @ExcludeMissing - fun _percent(): JsonField = percent + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -15492,40 +17310,101 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```java - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -15550,32 +17429,51 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - percent() + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -15594,26 +17492,39 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -15683,6 +17594,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -15732,12 +17653,13 @@ private constructor( return true } - return other is Percent && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -15749,6 +17671,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -15757,10 +17680,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -15772,6 +17695,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -15781,14 +17705,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class DailyCreditAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, + private val dailyCreditAllowanceConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -15804,6 +17728,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -15814,9 +17739,10 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), + dailyCreditAllowanceConfig: JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -15862,6 +17788,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -15870,7 +17799,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -15885,6 +17814,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -15900,14 +17830,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for event_output pricing + * Configuration for daily_credit_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") /** * The id of the item the price will be associated with. @@ -15923,7 +17853,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("daily_credit_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -16044,6 +17974,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -16074,14 +18012,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [eventOutputConfig]. + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("event_output_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig /** * Returns the raw JSON value of [itemId]. @@ -16212,6 +18151,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -16247,12 +18196,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowance]. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` @@ -16260,13 +18210,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [DailyCreditAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null + private var dailyCreditAllowanceConfig: JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -16285,31 +18236,36 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + currency = dailyCreditAllowance.currency + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + referenceId = dailyCreditAllowance.referenceId + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -16324,20 +18280,22 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -16357,7 +18315,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("daily_credit_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -16725,6 +18683,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -16789,24 +18768,24 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [DailyCreditAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): DailyCreditAllowance = + DailyCreditAllowance( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -16821,6 +18800,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -16829,16 +18809,26 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() + dailyCreditAllowanceConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("daily_credit_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -16854,6 +18844,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -16876,9 +18867,11 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -16891,6 +18884,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -17014,6 +19008,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -17053,87 +19057,144 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") + @JsonProperty("daily_allowance") @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") + @ExcludeMissing + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) /** - * The key in the event data to extract the unit rate from. + * Credits granted per day. Lose-it-or-use-it; does not roll over. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun defaultUnitRate(): Optional = - defaultUnitRate.getOptional("default_unit_rate") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. + * One or two event property values to evaluate matrix groups by * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + fun dimensions(): List = dimensions.getRequired("dimensions") /** - * Returns the raw JSON value of [unitRatingKey]. + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") + + /** + * Per-dimension credit rates + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_rating_key") + @JsonProperty("daily_allowance") @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun _dailyAllowance(): JsonField = dailyAllowance /** - * Returns the raw JSON value of [defaultUnitRate]. + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("default_unit_rate") + @JsonProperty("dimensions") @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun _dimensions(): JsonField> = dimensions /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [eventDayProperty]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("event_day_property") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _eventDayProperty(): JsonField = eventDayProperty + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -17151,235 +19212,583 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [DailyCreditAllowanceConfig]. * * The following fields are required: * ```java - * .unitRatingKey() + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [DailyCreditAllowanceConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. * - * You should usually call [Builder.unitRatingKey] with a well-typed + * You should usually call [Builder.dailyAllowance] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance } /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Alias for calling [Builder.defaultUnitRate] with - * `defaultUnitRate.orElse(null)`. + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value */ - fun defaultUnitRate(defaultUnitRate: Optional) = - defaultUnitRate(defaultUnitRate.getOrNull()) + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.defaultUnitRate] with a well-typed + * You should usually call [Builder.defaultUnitAmount] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) /** - * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + * Sets [Builder.dimensions] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: Optional) = - groupingKey(groupingKey.getOrNull()) + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Adds a single [String] to [dimensions]. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) /** - * Returns an immutable instance of [EventOutputConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .unitRatingKey() - * ``` + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. * - * @throws IllegalStateException if any required field is unset. + * You should usually call [Builder.eventDayProperty] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EventOutputConfig = apply { - if (validated) { - return@apply + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty } - unitRatingKey() - defaultUnitRate() - groupingKey() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (unitRatingKey.asKnown().isPresent) 1 else 0) + - (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + dimensionValues() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -17414,6 +19823,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -17463,9 +19882,9 @@ private constructor( return true } - return other is EventOutput && + return other is DailyCreditAllowance && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -17480,6 +19899,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -17488,7 +19908,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -17503,6 +19923,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -17512,5112 +19933,17381 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + "DailyCreditAllowance{cadence=$cadence, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } + class MeteredAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + meteredAllowanceConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - override fun hashCode(): Int = hashCode + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @Deprecated("deprecated") - class ExternalMarketplace - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Configuration for metered_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("metered_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - companion object { + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - @JvmField val GOOGLE = of("google") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - @JvmField val AWS = of("aws") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - @JvmField val AZURE = of("azure") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - @JvmStatic fun of(value: String) = ExternalMarketplace(JsonField.of(value)) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - /** An enum containing [ExternalMarketplace]'s known values. */ - enum class Known { - GOOGLE, - AWS, - AZURE, - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** - * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE, - AWS, - AZURE, - /** - * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE -> Value.GOOGLE - AWS -> Value.AWS - AZURE -> Value.AZURE - else -> Value._UNKNOWN - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE -> Known.GOOGLE - AWS -> Known.AWS - AZURE -> Known.AZURE - else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - private var validated: Boolean = false + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - fun validate(): ExternalMarketplace = apply { - if (validated) { - return@apply - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - known() - validated = true - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - return other is ExternalMarketplace && value == other.value - } + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - companion object { + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** A builder for [Metadata]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + /** + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .meteredAllowanceConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [MeteredAllowance]. */ + class Builder internal constructor() { - return other is Metadata && additionalProperties == other.additionalProperties - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + @JvmSynthetic + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + currency = meteredAllowance.currency + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + referenceId = meteredAllowance.referenceId + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } - override fun hashCode(): Int = hashCode + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) - - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } - fun toBuilder() = Builder().from(this) + /** + * 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("metered_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - companion object { + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - @JvmSynthetic - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - private var validated: Boolean = false + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - adjustmentId() - validated = true - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): Optional = priceId.getOptional("price_id") + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmSynthetic - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ - fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - private var validated: Boolean = false + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - externalPriceId() - priceId() - validated = true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (priceId.asKnown().isPresent) 1 else 0) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + /** + * Returns an immutable instance of [MeteredAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .meteredAllowanceConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MeteredAllowance = + MeteredAllowance( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { + if (validated) { + return@apply + } - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + cadence().validate() + itemId() + meteredAllowanceConfig().validate() + _modelType().let { + if (it != JsonValue.from("metered_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + companion object { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val ANNUAL = of("annual") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun toBuilder() = Builder().from(this) + @JvmField val MONTHLY = of("monthly") - companion object { + @JvmField val QUARTERLY = of("quarterly") - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmField val ONE_TIME = of("one_time") - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + @JvmField val CUSTOM = of("custom") - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + private var validated: Boolean = false - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + known() + validated = true + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + return other is Cadence && value == other.value + } - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + override fun hashCode() = value.hashCode() - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + override fun toString() = value.toString() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, + private val additionalProperties: MutableMap, + ) { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonCreator + private constructor( + @JsonProperty("allowance_grouping_value") + @ExcludeMissing + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") + @ExcludeMissing + consumptionGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), + ) : this( + allowanceGroupingValue, + consumptionGroupingValue, + groupingKey, + unitAmount, + allowanceDisplayName, + consumptionDisplayName, + mutableMapOf(), + ) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + /** + * Per-unit price applied to gross consumption and to the allowance credit. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - private var validated: Boolean = false + /** + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") - adjustment().validate() - replacesAdjustmentId() - validated = true - } + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_grouping_value") + @ExcludeMissing + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [consumptionGroupingValue]. + * + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumption_grouping_value") + @ExcludeMissing + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun minimum(): Optional = Optional.ofNullable(minimum) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun maximum(): Optional = Optional.ofNullable(maximum) + fun toBuilder() = Builder().from(this) - fun isPercentageDiscount(): Boolean = percentageDiscount != null + companion object { - fun isUsageDiscount(): Boolean = usageDiscount != null + /** + * Returns a mutable builder for constructing an instance of + * [MeteredAllowanceConfig]. + * + * The following fields are required: + * ```java + * .allowanceGroupingValue() + * .consumptionGroupingValue() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isAmountDiscount(): Boolean = amountDiscount != null + /** A builder for [MeteredAllowanceConfig]. */ + class Builder internal constructor() { - fun isMinimum(): Boolean = minimum != null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - fun isMaximum(): Boolean = maximum != null + @JvmSynthetic + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName + additionalProperties = + meteredAllowanceConfig.additionalProperties.toMutableMap() + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + /** + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + /** + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - private var validated: Boolean = false + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [MeteredAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowanceGroupingValue() + * .consumptionGroupingValue() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, + additionalProperties.toMutableMap(), + ) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { + if (validated) { + return@apply + } - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + allowanceGroupingValue() + consumptionGroupingValue() + groupingKey() + unitAmount() + allowanceDisplayName() + consumptionDisplayName() + validated = true + } - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun unknown(json: JsonValue?) = 0 + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && + additionalProperties == other.additionalProperties } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private val hashCode: Int by lazy { + Objects.hash( + allowanceGroupingValue, + consumptionGroupingValue, + groupingKey, + unitAmount, + allowanceDisplayName, + consumptionDisplayName, + additionalProperties, + ) + } - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + override fun hashCode(): Int = hashCode - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) - - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") + override fun toString() = + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } - companion object { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + fun toBuilder() = Builder().from(this) - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + companion object { - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + private var additionalProperties: MutableMap = + mutableMapOf() - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitMinimum(minimum: NewMinimum): T + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun visitMaximum(maximum: NewMaximum): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + private var validated: Boolean = false - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Adjustment(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Adjustment::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - additionalProperties == other.additionalProperties - } + return other is MeteredAllowance && + cadence == other.cadence && + itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + meteredAllowanceConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } + override fun toString() = + "MeteredAllowance{cadence=$cadence, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * The id of the price on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): Optional = - allocationPrice.getOptional("allocation_price") + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): Optional> = discounts.getOptional("discounts") + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * New subscription price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): Optional = priceId.getOptional("price_id") + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - companion object { + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** Alias for calling [Builder.discounts] with `discounts.orElse(null)`. */ - @Deprecated("deprecated") - fun discounts(discounts: Optional>) = - discounts(discounts.getOrNull()) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** - * Adds a single [DiscountOverride] to [discounts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) - } - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + companion object { - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) + /** A builder for [Percent]. */ + class Builder internal constructor() { - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + @JvmSynthetic + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } - /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.getOrNull()) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** Alias for calling [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. - */ - fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = - price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ - fun price(minimumComposite: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimumComposite(minimumComposite)) + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ - fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) - - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toMutableMap(), - ) - } + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - private var validated: Boolean = false + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - discounts().ifPresent { it.forEach { it.validate() } } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price().ifPresent { it.validate() } - priceId() - validated = true - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) + - (if (priceId.asKnown().isPresent) 1 else 0) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewSubscriptionMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun unit(): Optional = Optional.ofNullable(unit) + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - fun tiered(): Optional = Optional.ofNullable(tiered) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun bulk(): Optional = Optional.ofNullable(bulk) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun package_(): Optional = Optional.ofNullable(package_) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun matrix(): Optional = Optional.ofNullable(matrix) + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun groupedWithProratedMinimum(): - Optional = - Optional.ofNullable(groupedWithProratedMinimum) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun groupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(groupedWithMeteredMinimum) + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun groupedWithMinMaxThresholds(): Optional = - Optional.ofNullable(groupedWithMinMaxThresholds) + private var validated: Boolean = false - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Percent = apply { + if (validated) { + return@apply + } - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the 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 cumulativeGroupedAllocation(): Optional = - Optional.ofNullable(cumulativeGroupedAllocation) + companion object { - fun minimumComposite(): Optional = - Optional.ofNullable(minimumComposite) + @JvmField val ANNUAL = of("annual") - fun percent(): Optional = Optional.ofNullable(percent) + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + @JvmField val MONTHLY = of("monthly") - fun isUnit(): Boolean = unit != null + @JvmField val QUARTERLY = of("quarterly") - fun isTiered(): Boolean = tiered != null + @JvmField val ONE_TIME = of("one_time") - fun isBulk(): Boolean = bulk != null + @JvmField val CUSTOM = of("custom") - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun isPackage(): Boolean = package_ != null + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun isMatrix(): Boolean = matrix != null - - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - - fun isTieredPackage(): Boolean = tieredPackage != null - - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - fun isUnitWithPercent(): Boolean = unitWithPercent != null + private var validated: Boolean = false - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun isTieredWithProration(): Boolean = tieredWithProration != null + known() + validated = true + } - fun isUnitWithProration(): Boolean = unitWithProration != null + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun isBulkWithProration(): Boolean = bulkWithProration != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + return other is Cadence && value == other.value + } - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + override fun hashCode() = value.hashCode() - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + override fun toString() = value.toString() + } - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun toBuilder() = Builder().from(this) - fun isMinimumComposite(): Boolean = minimumComposite != null + companion object { - fun isPercent(): Boolean = percent != null + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isEventOutput(): Boolean = eventOutput != null + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() + } - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + private var validated: Boolean = false - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): PercentConfig = apply { + if (validated) { + return@apply + } - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + percent() + validated = true + } - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + override fun hashCode(): Int = hashCode - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + fun toBuilder() = Builder().from(this) - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + companion object { - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** A builder for [Metadata]. */ + class Builder internal constructor() { - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + private var additionalProperties: MutableMap = + mutableMapOf() - fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = - cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun asMinimumComposite(): NewSubscriptionMinimumCompositePrice = - minimumComposite.getOrThrow("minimumComposite") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun asPercent(): Percent = percent.getOrThrow("percent") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun _json(): Optional = Optional.ofNullable(_json) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - cumulativeGroupedAllocation != null -> - visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) - minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - private var validated: Boolean = false + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - fun validate(): Price = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + validated = true + } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + return other is Metadata && + additionalProperties == other.additionalProperties + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + override fun hashCode(): Int = hashCode - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } - - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() - } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() - } + override fun hashCode(): Int = hashCode - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() - } + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) { - cumulativeGroupedAllocation.validate() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - override fun visitMinimumComposite( - minimumComposite: NewSubscriptionMinimumCompositePrice - ) { - minimumComposite.validate() - } + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - override fun visitPercent(percent: Percent) { - percent.validate() - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } - } - ) - validated = true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() - - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() - - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + fun toBuilder() = Builder().from(this) - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = cumulativeGroupedAllocation.validity() + companion object { - override fun visitMinimumComposite( - minimumComposite: NewSubscriptionMinimumCompositePrice - ) = minimumComposite.validity() + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitPercent(percent: Percent) = percent.validity() + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun unknown(json: JsonValue?) = 0 + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && - minimumComposite == other.minimumComposite && - percent == other.percent && - eventOutput == other.eventOutput - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - cumulativeGroupedAllocation, - minimumComposite, - percent, - eventOutput, - ) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - companion object { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JvmStatic - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - @JvmStatic - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - @JvmStatic - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - @JvmStatic - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) - - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) - - @JvmStatic - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) - - @JvmStatic - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - @JvmStatic - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - @JvmStatic - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - @JvmStatic - fun ofCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - @JvmStatic - fun ofMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun visitUnit(unit: NewSubscriptionUnitPrice): T + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ): T + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun visitMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitPercent(percent: Percent): T + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun visitEventOutput(eventOutput: EventOutput): T + private var validated: Boolean = false /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException in the default implementation. + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - internal class Deserializer : BaseDeserializer(Price::class) { + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) - } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) - } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.cumulativeGroupedAllocation != null -> - generator.writeObject(value.cumulativeGroupedAllocation) - value.minimumComposite != null -> - generator.writeObject(value.minimumComposite) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } + } - class BulkWithFilters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val bulkWithFiltersConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bulkWithFiltersConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + metricParameterOverrides, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + @Deprecated("deprecated") + class ExternalMarketplace + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE = of("google") + + @JvmField val AWS = of("aws") + + @JvmField val AZURE = of("azure") + + @JvmStatic fun of(value: String) = ExternalMarketplace(JsonField.of(value)) + } + + /** An enum containing [ExternalMarketplace]'s known values. */ + enum class Known { + GOOGLE, + AWS, + AZURE, + } + + /** + * An enum containing [ExternalMarketplace]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ExternalMarketplace] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE, + AWS, + AZURE, + /** + * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE -> Value.GOOGLE + AWS -> Value.AWS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GOOGLE -> Known.GOOGLE + AWS -> Known.AWS + AZURE -> Known.AZURE + else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ExternalMarketplace = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalMarketplace && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) + + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) + + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): Optional = priceId.getOptional("price_id") + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + externalPriceId() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(maximum) + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + metricParameterOverrides, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): Optional = + allocationPrice.getOptional("allocation_price") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): Optional> = discounts.getOptional("discounts") + + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Optional = price.getOptional("price") + + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): Optional = priceId.getOptional("price_id") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + metricParameterOverrides = replacePrice.metricParameterOverrides + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) + + /** Alias for calling [Builder.discounts] with `discounts.orElse(null)`. */ + @Deprecated("deprecated") + fun discounts(discounts: Optional>) = + discounts(discounts.getOrNull()) + + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ + fun price(minimumComposite: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimumComposite(minimumComposite)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + metricParameterOverrides, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice().ifPresent { it.validate() } + discounts().ifPresent { it.forEach { it.validate() } } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } + minimumAmount() + price().ifPresent { it.validate() } + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @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 + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, + private val minimumComposite: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): + Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): + Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + + fun asMinimumComposite(): NewSubscriptionMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewSubscriptionUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewSubscriptionMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + + override fun visitMinimumComposite( + minimumComposite: NewSubscriptionMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + matrixWithThresholdDiscounts, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + @JvmStatic + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + + fun visitMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithThresholdDiscounts + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Configuration for matrix_with_threshold_discounts pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_threshold_discounts") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscounts]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscounts]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null + private var modelType: JsonValue = + JsonValue.from("matrix_with_threshold_discounts") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = + apply { + cadence = matrixWithThresholdDiscounts.cadence + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance + billingCycleConfiguration = + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + currency = matrixWithThresholdDiscounts.currency + dimensionalPriceConfiguration = + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata + referenceId = matrixWithThresholdDiscounts.referenceId + additionalProperties = + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + + /** + * 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_with_threshold_discounts") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired( + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + matrixWithThresholdDiscountsConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) + + /** + * Unit price used for usage that does not match any defined matrix cell. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** + * First matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Per-cell unit prices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Optional second matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscountsConfig]. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ + class Builder internal constructor() { + + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = apply { + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } + additionalProperties = + matrixWithThresholdDiscountsConfig.additionalProperties + .toMutableMap() + } + + /** + * Unit price used for usage that does not match any defined matrix cell. + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + @JvmField val SEMI_ANNUAL = of("semi_annual") - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + @JvmField val MONTHLY = of("monthly") - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JvmField val QUARTERLY = of("quarterly") - /** - * The pricing model type - * - * Expected to always return the following: - * ```java - * JsonValue.from("bulk_with_filters") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + @JvmField val ONE_TIME = of("one_time") - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + @JvmField val CUSTOM = of("custom") - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + private var validated: Boolean = false - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + known() + validated = true + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + return other is Cadence && value == other.value + } - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + companion object { - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithFilters]. */ - class Builder internal constructor() { - - private var bulkWithFiltersConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + tiers().forEach { it.validate() } + validated = true } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * 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("bulk_with_filters") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + companion object { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + companion object { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + private var additionalProperties: MutableMap = + mutableMapOf() - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + private var validated: Boolean = false /** - * Alias for [Builder.fixedPriceQuantity]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + validated = true + } - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + override fun hashCode(): Int = hashCode - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Returns an immutable instance of [BulkWithFilters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - private var validated: Boolean = false + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun validate(): BulkWithFilters = apply { - if (validated) { - return@apply - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - bulkWithFiltersConfig().validate() - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * The configuration for the rate of the price currency to the invoicing currency. * - * Used for best match union deserialization. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JvmSynthetic - internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - @JsonCreator - private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Bulk tiers for rating based on total usage volume - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - fun toBuilder() = Builder().from(this) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - companion object { + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** A builder for [BulkWithFiltersConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var filters: JsonField>? = null - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns an immutable instance of [BulkWithFiltersConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun validate(): BulkWithFiltersConfig = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - filters().forEach { it.validate() } - tiers().forEach { it.validate() } - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * - * Used for best match union deserialization. + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` */ - @JvmSynthetic - internal fun validity(): Int = - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) + @JvmStatic fun builder() = Builder() + } - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - companion object { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** A builder for [Filter]. */ - class Builder internal constructor() { + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JvmSynthetic - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): Filter = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - propertyKey() - propertyValue() - validated = true - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (propertyKey.asKnown().isPresent) 1 else 0) + - (if (propertyValue.asKnown().isPresent) 1 else 0) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - companion object { + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** A builder for [Tier]. */ - class Builder internal constructor() { + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - private var validated: Boolean = false + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun validate(): Tier = apply { - if (validated) { - return@apply - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - unitAmount() - tierLowerBound() - validated = true - } + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) /** The cadence to bill for this price on. */ class Cadence @@ -22739,6 +37429,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -22778,6 +37478,342 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -22845,6 +37881,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -22894,9 +37940,10 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -22911,6 +37958,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -22918,8 +37966,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -22934,6 +37982,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -22943,17 +37992,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -22966,6 +38016,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -22976,6 +38027,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -22985,10 +38041,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -23025,6 +38077,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -23033,10 +38088,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -23048,6 +38103,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -23062,6 +38118,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -23076,7 +38144,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -23093,16 +38161,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -23207,6 +38265,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -23236,6 +38302,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -23252,17 +38329,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -23376,6 +38442,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -23412,28 +38488,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -23451,35 +38529,40 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -23493,6 +38576,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -23511,7 +38617,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -23531,22 +38637,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -23895,6 +38985,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -23959,27 +39070,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -23991,6 +39105,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -23999,20 +39114,30 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -24024,6 +39149,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -24046,12 +39172,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -24063,6 +39189,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -24186,6 +39313,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -24225,40 +39362,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("cumulative_allocation") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [tiers]. + * The allocation per individual group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -24276,59 +39488,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -24354,32 +39607,51 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -24399,249 +39671,38 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -24711,6 +39772,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -24760,12 +39831,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -24777,6 +39849,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -24785,10 +39858,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -24800,6 +39873,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -24809,15 +39883,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class DailyCreditAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val dailyCreditAllowanceConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -24833,6 +39906,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -24843,10 +39917,9 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = + dailyCreditAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -24893,6 +39966,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -24901,7 +39977,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -24916,6 +39992,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -24931,16 +40008,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for daily_credit_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") /** * The id of the item the price will be associated with. @@ -24956,7 +40031,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -25077,6 +40152,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -25107,15 +40190,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig /** * Returns the raw JSON value of [itemId]. @@ -25246,6 +40329,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -25282,12 +40375,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [DailyCreditAllowance]. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` @@ -25295,16 +40388,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [DailyCreditAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = + private var dailyCreditAllowanceConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -25323,38 +40414,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + currency = dailyCreditAllowance.currency + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + referenceId = dailyCreditAllowance.referenceId + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -25368,28 +40458,22 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -25409,7 +40493,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -25777,6 +40861,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -25841,27 +40946,24 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [DailyCreditAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): DailyCreditAllowance = + DailyCreditAllowance( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -25876,6 +40978,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -25884,16 +40987,26 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + dailyCreditAllowanceConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("daily_credit_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -25909,6 +41022,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -25931,10 +41045,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -25948,6 +41062,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -26071,6 +41186,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -26110,108 +41235,144 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Credits granted per day. Lose-it-or-use-it; does not roll over. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") /** - * The maximum amount to charge each group + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The minimum amount to charge each group, regardless of usage + * One or two event property values to evaluate matrix groups by * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun dimensions(): List = dimensions.getRequired("dimensions") /** - * The base price charged per group + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") /** - * Returns the raw JSON value of [groupingKey]. + * Per-dimension credit rates * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _dailyAllowance(): JsonField = dailyAllowance /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("dimensions") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _dimensions(): JsonField> = dimensions /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [eventDayProperty]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("event_day_property") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _eventDayProperty(): JsonField = eventDayProperty /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("matrix_values") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _matrixValues(): JsonField> = matrixValues @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -26229,100 +41390,583 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [DailyCreditAllowanceConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [DailyCreditAllowanceConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.defaultUnitAmount] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.dimensions] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) + + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + dimensionValues() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -26348,161 +41992,25 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply - } - - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Validates that the types of all values in this object match their expected + * types recursively. * - * Used for best match union deserialization. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - fun validate(): Metadata = apply { if (validated) { return@apply @@ -26552,10 +42060,9 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is DailyCreditAllowance && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -26570,6 +42077,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26578,7 +42086,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -26593,6 +42101,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26602,16 +42111,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -26626,6 +42134,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26636,14 +42145,12 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -26686,6 +42193,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26694,8 +42204,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -26709,6 +42219,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -26724,32 +42235,30 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for metered_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -26870,6 +42379,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -26899,17 +42416,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [itemId]. * @@ -26918,6 +42424,17 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + /** * Returns the raw JSON value of [name]. * @@ -27039,6 +42556,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -27074,30 +42601,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -27116,38 +42639,35 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + currency = meteredAllowance.currency + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + referenceId = meteredAllowance.referenceId + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -27161,29 +42681,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -27196,13 +42693,28 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + /** * 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("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -27570,6 +43082,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27634,28 +43167,25 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), modelType, checkRequired("name", name), billableMetricId, @@ -27669,6 +43199,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27677,16 +43208,26 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() itemId() + meteredAllowanceConfig().validate() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -27702,6 +43243,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -27724,11 +43266,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -27741,6 +43281,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -27864,6 +43405,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -27903,60 +43454,76 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), ) : this( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, mutableMapOf(), ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -27965,7 +43532,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -27974,24 +43541,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -28013,6 +43598,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -28029,12 +43634,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -28042,61 +43647,75 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) @@ -28111,7 +43730,9 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -28125,6 +43746,37 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -28148,41 +43800,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -28202,30 +43868,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -28233,7 +43905,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } /** @@ -28303,6 +43975,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -28352,11 +44034,10 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -28370,6 +44051,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -28378,8 +44060,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -28393,6 +44075,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -28402,7 +44085,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MeteredAllowance{cadence=$cadence, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -28425,6 +44108,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -28483,6 +44167,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -28506,6 +44193,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -28664,6 +44352,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -28832,6 +44528,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -28905,6 +44611,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -28927,6 +44634,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -29345,6 +45053,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -29441,6 +45170,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -29449,6 +45179,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -29474,6 +45214,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -29511,6 +45252,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -29634,6 +45376,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -29801,6 +45553,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -29914,6 +45676,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -29980,6 +45752,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -30003,6 +45776,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -30012,7 +45786,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -30035,6 +45809,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -30093,6 +45868,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -30116,6 +45894,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -30275,6 +46054,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -30443,6 +46230,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -30516,6 +46313,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -30538,6 +46336,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -30956,6 +46755,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -31052,6 +46872,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -31060,6 +46881,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -31085,6 +46916,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -31122,6 +46954,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -31245,6 +47078,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -31520,6 +47363,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -31645,6 +47498,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -31711,6 +47574,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -31734,6 +47598,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -31743,7 +47608,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -31759,6 +47624,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && @@ -31773,6 +47639,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -31783,7 +47650,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { 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 4fe0b5919..385232df0 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 @@ -22,9 +22,9 @@ import kotlin.jvm.optionals.getOrNull * rather than a currency). * * The semantics of this endpoint exactly mirror those of - * [fetching a customer's costs](fetch-customer-costs). Use this endpoint to limit your analysis 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). + * [fetching a customer's costs](/api-reference/customer/fetch-customer-costs). Use this endpoint to + * limit your analysis 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). */ class SubscriptionFetchCostsParams private constructor( @@ -362,6 +362,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ViewMode = apply { if (validated) { return@apply 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 fb2a57cf6..29bf775c3 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 @@ -149,6 +149,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionFetchCostsResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt index 068ffead9..977043977 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageResponse.kt @@ -193,6 +193,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionFetchSchedulePageResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt index 13cb82088..1ca8caf3e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt @@ -242,6 +242,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionFetchScheduleResponse = apply { if (validated) { return@apply @@ -476,6 +484,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Plan = apply { if (validated) { return@apply 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 29934eb7a..fe1efa4ef 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 @@ -620,6 +620,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Granularity = apply { if (validated) { return@apply @@ -749,6 +758,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ViewMode = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt index eb44b0f40..b448134e0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt @@ -459,6 +459,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Status = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt index 88929fc84..f02a0d03c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinified.kt @@ -124,6 +124,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionMinified = apply { if (validated) { return@apply 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 78a8ddd69..bacedc9a0 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 @@ -945,6 +945,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -1027,6 +1036,7 @@ private constructor( private val filter: JsonField, private val fixedFeeQuantityTransitions: JsonField>, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val price: JsonField, private val priceId: JsonField, @@ -1062,6 +1072,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -1080,6 +1093,7 @@ private constructor( filter, fixedFeeQuantityTransitions, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -1167,6 +1181,16 @@ private constructor( */ fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * The minimum amount that will be billed for this price interval for a given billing * period. @@ -1288,6 +1312,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -1361,6 +1396,8 @@ private constructor( JsonField>? = null private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -1379,6 +1416,7 @@ private constructor( fixedFeeQuantityTransitions = add.fixedFeeQuantityTransitions.map { it.toMutableList() } maximumAmount = add.maximumAmount + metricParameterOverrides = add.metricParameterOverrides minimumAmount = add.minimumAmount price = add.price priceId = add.priceId @@ -1672,6 +1710,32 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values (number or string). + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * The minimum amount that will be billed for this price interval for a given billing * period. @@ -1777,6 +1841,13 @@ private constructor( fun price(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -1866,6 +1937,16 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: NewFloatingMinimumCompositePrice) = price(Price.ofMinimumComposite(minimumComposite)) @@ -1973,6 +2054,7 @@ private constructor( filter, (fixedFeeQuantityTransitions ?: JsonMissing.of()).map { it.toImmutable() }, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -1983,6 +2065,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Add = apply { if (validated) { return@apply @@ -1997,6 +2088,7 @@ private constructor( filter() fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } minimumAmount() price().ifPresent { it.validate() } priceId() @@ -2030,6 +2122,7 @@ private constructor( (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + @@ -2064,6 +2157,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = startDate.accept(new StartDate.Visitor>() { + * @Override + * public Optional visitDateTime(OffsetDateTime dateTime) { + * return Optional.of(dateTime.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { dateTime != null -> visitor.visitDateTime(dateTime) @@ -2074,6 +2197,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StartDate = apply { if (validated) { return@apply @@ -2253,6 +2386,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = discount.accept(new Discount.Visitor>() { + * @Override + * public Optional visitAmount(Amount amount) { + * return Optional.of(amount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { amount != null -> visitor.visitAmount(amount) @@ -2263,6 +2426,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Discount = apply { if (validated) { return@apply @@ -2583,6 +2756,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Amount = apply { if (validated) { return@apply @@ -2806,6 +2989,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Percentage = apply { if (validated) { return@apply @@ -3028,6 +3221,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Usage = apply { if (validated) { return@apply @@ -3112,6 +3315,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = endDate.accept(new EndDate.Visitor>() { + * @Override + * public Optional visitDateTime(OffsetDateTime dateTime) { + * return Optional.of(dateTime.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { dateTime != null -> visitor.visitDateTime(dateTime) @@ -3122,6 +3355,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EndDate = apply { if (validated) { return@apply @@ -3439,6 +3682,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): FixedFeeQuantityTransition = apply { if (validated) { return@apply @@ -3489,6 +3742,129 @@ private constructor( "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" } + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + */ + class MetricParameterOverrides + @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 + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New floating price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -3508,6 +3884,7 @@ private constructor( private val packageWithAllocation: NewFloatingPackageWithAllocationPrice? = null, private val unitWithPercent: NewFloatingUnitWithPercentPrice? = null, private val matrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, private val tieredWithProration: NewFloatingTieredWithProrationPrice? = null, private val unitWithProration: NewFloatingUnitWithProrationPrice? = null, private val groupedAllocation: NewFloatingGroupedAllocationPrice? = null, @@ -3528,6 +3905,8 @@ private constructor( null, private val cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, private val minimumComposite: NewFloatingMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -3570,6 +3949,9 @@ private constructor( fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -3614,6 +3996,12 @@ private constructor( fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) @@ -3649,6 +4037,8 @@ private constructor( fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null @@ -3678,6 +4068,10 @@ private constructor( fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + fun isMinimumComposite(): Boolean = minimumComposite != null fun isPercent(): Boolean = percent != null @@ -3720,6 +4114,9 @@ private constructor( fun asMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + fun asTieredWithProration(): NewFloatingTieredWithProrationPrice = tieredWithProration.getOrThrow("tieredWithProration") @@ -3763,6 +4160,12 @@ private constructor( fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + fun asMinimumComposite(): NewFloatingMinimumCompositePrice = minimumComposite.getOrThrow("minimumComposite") @@ -3772,6 +4175,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewFloatingUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) @@ -3792,6 +4225,8 @@ private constructor( unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) @@ -3819,6 +4254,9 @@ private constructor( visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) cumulativeGroupedAllocation != null -> visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -3827,6 +4265,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Price = apply { if (validated) { return@apply @@ -3906,6 +4354,12 @@ private constructor( matrixWithAllocation.validate() } + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) { @@ -3992,6 +4446,16 @@ private constructor( cumulativeGroupedAllocation.validate() } + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + override fun visitMinimumComposite( minimumComposite: NewFloatingMinimumCompositePrice ) { @@ -4074,6 +4538,10 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ) = matrixWithAllocation.validity() + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + override fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ) = tieredWithProration.validity() @@ -4132,6 +4600,13 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + override fun visitMinimumComposite( minimumComposite: NewFloatingMinimumCompositePrice ) = minimumComposite.validity() @@ -4165,6 +4640,7 @@ private constructor( packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && @@ -4179,6 +4655,8 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && minimumComposite == other.minimumComposite && percent == other.percent && eventOutput == other.eventOutput @@ -4200,6 +4678,7 @@ private constructor( packageWithAllocation, unitWithPercent, matrixWithAllocation, + matrixWithThresholdDiscounts, tieredWithProration, unitWithProration, groupedAllocation, @@ -4214,6 +4693,8 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, minimumComposite, percent, eventOutput, @@ -4239,6 +4720,8 @@ private constructor( unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" @@ -4263,6 +4746,9 @@ private constructor( "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -4323,6 +4809,11 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ) = Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + @JvmStatic fun ofTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice @@ -4390,6 +4881,14 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + @JvmStatic fun ofMinimumComposite(minimumComposite: NewFloatingMinimumCompositePrice) = Price(minimumComposite = minimumComposite) @@ -4441,6 +4940,10 @@ private constructor( matrixWithAllocation: NewFloatingMatrixWithAllocationPrice ): T + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + fun visitTieredWithProration( tieredWithProration: NewFloatingTieredWithProrationPrice ): T @@ -4491,6 +4994,10 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + fun visitMinimumComposite(minimumComposite: NewFloatingMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -4609,6 +5116,14 @@ private constructor( ?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } "tiered_with_proration" -> { return tryDeserialize( node, @@ -4723,6 +5238,16 @@ private constructor( ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } ?: Price(_json = json) } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } "minimum_composite" -> { return tryDeserialize( node, @@ -4776,6 +5301,8 @@ private constructor( generator.writeObject(value.unitWithPercent) value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> @@ -4804,6 +5331,10 @@ private constructor( generator.writeObject(value.cumulativeGroupedBulk) value.cumulativeGroupedAllocation != null -> generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) value.minimumComposite != null -> generator.writeObject(value.minimumComposite) value.percent != null -> generator.writeObject(value.percent) @@ -4834,6 +5365,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -4891,6 +5423,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -4911,6 +5446,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -5069,6 +5605,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -5229,6 +5773,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -5293,6 +5847,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5315,6 +5870,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() } @@ -5726,6 +6282,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -5801,6 +6378,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -5808,6 +6386,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): BulkWithFilters = apply { if (validated) { return@apply @@ -5833,6 +6421,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -5869,6 +6458,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** Configuration for bulk_with_filters pricing */ @@ -6070,6 +6660,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply @@ -6273,6 +6873,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -6502,6 +7112,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -6693,6 +7313,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -6799,6 +7429,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -6865,6 +7505,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -6887,6 +7528,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -6895,17 +7537,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class MatrixWithThresholdDiscounts @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val currency: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -6919,6 +7561,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -6931,14 +7574,14 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -6978,14 +7621,17 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, currency, - groupedWithMinMaxThresholdsConfig, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, billableMetricId, @@ -6998,6 +7644,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -7021,32 +7668,32 @@ private constructor( fun currency(): String = currency.getRequired("currency") /** - * Configuration for grouped_with_min_max_thresholds pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for matrix_with_threshold_discounts pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -7158,6 +7805,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -7188,17 +7843,6 @@ private constructor( @ExcludeMissing fun _currency(): JsonField = currency - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -7207,6 +7851,18 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig + /** * Returns the raw JSON value of [name]. * @@ -7318,6 +7974,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -7344,31 +8010,31 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [MatrixWithThresholdDiscounts]. * * The following fields are required: * ```java * .cadence() * .currency() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [MatrixWithThresholdDiscounts]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + JsonValue.from("matrix_with_threshold_discounts") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7386,35 +8052,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = apply { - cadence = groupedWithMinMaxThresholds.cadence - currency = groupedWithMinMaxThresholds.currency - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + cadence = matrixWithThresholdDiscounts.cadence + currency = matrixWithThresholdDiscounts.currency + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -7441,29 +8109,6 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -7476,13 +8121,36 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -7832,6 +8500,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7874,7 +8563,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7882,22 +8571,22 @@ private constructor( * ```java * .cadence() * .currency() - * .groupedWithMinMaxThresholdsConfig() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( checkRequired("cadence", cadence), checkRequired("currency", currency), + checkRequired("itemId", itemId), checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, ), - checkRequired("itemId", itemId), modelType, checkRequired("name", name), billableMetricId, @@ -7910,6 +8599,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -7917,17 +8607,27 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { if (validated) { return@apply } cadence().validate() currency() - groupedWithMinMaxThresholdsConfig().validate() itemId() + matrixWithThresholdDiscountsConfig().validate() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -7942,6 +8642,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -7964,10 +8665,11 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -7980,6 +8682,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -8102,6 +8805,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -8141,108 +8854,140 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Unit price used for usage that does not match any defined matrix cell. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The maximum amount to charge each group + * First matrix dimension key. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") /** - * The minimum amount to charge each group, regardless of usage + * Per-cell unit prices. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") /** - * The base price charged per group + * Optional second matrix dimension key. * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") /** - * Returns the raw JSON value of [groupingKey]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("default_unit_amount") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [firstDimension]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [firstDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("first_dimension") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _firstDimension(): JsonField = firstDimension /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("matrix_values") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _matrixValues(): JsonField> = matrixValues /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [secondDimension]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [secondDimension], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("second_dimension") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -8260,203 +9005,6848 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [MatrixWithThresholdDiscountsConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties + matrixWithThresholdDiscountsConfig.additionalProperties .toMutableMap() } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** + * Unit price used for usage that does not match any defined matrix cell. + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.firstDimension] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.firstDimension] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + currency == other.currency && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + currency = groupedWithMinMaxThresholds.currency + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) + + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholds && + cadence == other.cadence && + currency == other.currency && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + currency, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class CumulativeGroupedAllocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, + private val currency: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocation]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + currency = cumulativeGroupedAllocation.currency + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedAllocationConfig() + * .currency() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( + checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { + if (validated) { + return@apply + } + + cadence().validate() + cumulativeGroupedAllocationConfig().validate() + currency() + itemId() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("cumulative_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) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cumulative_allocation") + @ExcludeMissing + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) + + /** + * The overall allocation across all groups + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") + + /** + * The allocation per individual group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocationConfig]. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedAllocationConfig]. */ + class Builder internal constructor() { + + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) + + /** + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { + if (validated) { + return@apply + } + + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CumulativeGroupedAllocation && + cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && + currency == other.currency && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + cumulativeGroupedAllocationConfig, + currency, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + class DailyCreditAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val currency: JsonField, + private val dailyCreditAllowanceConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + dailyCreditAllowanceConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + ) : this( + cadence, + currency, + dailyCreditAllowanceConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string for which this price is billed in. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Configuration for daily_credit_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. + * + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("daily_credit_allowance_config") + @ExcludeMissing + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DailyCreditAllowance]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var dailyCreditAllowanceConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + currency = dailyCreditAllowance.currency + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) + + /** + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("daily_credit_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .dailyCreditAllowanceConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowance = + DailyCreditAllowance( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { + if (validated) { + return@apply + } + + cadence().validate() + currency() + dailyCreditAllowanceConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("daily_credit_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("daily_allowance") + @ExcludeMissing + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") + @ExcludeMissing + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) + + /** + * Credits granted per day. Lose-it-or-use-it; does not roll over. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** + * One or two event property values to evaluate matrix groups by + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") + + /** + * Per-dimension credit rates + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("daily_allowance") + @ExcludeMissing + fun _dailyAllowance(): JsonField = dailyAllowance + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + /** + * Returns the raw JSON value of [eventDayProperty]. + * + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_day_property") + @ExcludeMissing + fun _eventDayProperty(): JsonField = eventDayProperty + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowanceConfig]. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DailyCreditAllowanceConfig]. */ + class Builder internal constructor() { + + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } + + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) + + /** + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. + * + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance + } + + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** + * Sets [Builder.dimensions] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) + + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty + } + + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + private var validated: Boolean = false /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Validates that the types of all values in this object match their + * expected types recursively. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge - } - - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) - - /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + fun validate(): MatrixValue = apply { + if (validated) { + return@apply } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + dimensionValues() + unitAmount() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` + * Returns a score indicating how many valid values are contained in this + * object recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, additionalProperties, ) } @@ -8464,7 +15854,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } /** @@ -8534,6 +15924,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -8583,11 +15983,10 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is DailyCreditAllowance && cadence == other.cadence && currency == other.currency && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -8601,6 +16000,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -8609,7 +16009,7 @@ private constructor( Objects.hash( cadence, currency, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -8623,6 +16023,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -8631,17 +16032,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, currency=$currency, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, currency=$currency, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val currency: JsonField, private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -8655,6 +16055,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -8664,17 +16065,15 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -8714,14 +16113,17 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, currency, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -8734,6 +16136,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -8748,41 +16151,39 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * An ISO 4217 currency string for which this price is billed in. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun currency(): String = currency.getRequired("currency") /** - * An ISO 4217 currency string for which this price is billed in. + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun currency(): String = currency.getRequired("currency") + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for metered_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -8894,6 +16295,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -8914,17 +16323,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [currency]. * @@ -8943,6 +16341,17 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + /** * Returns the raw JSON value of [name]. * @@ -9054,6 +16463,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -9079,32 +16498,28 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .currency() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -9122,36 +16537,33 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - currency = cumulativeGroupedAllocation.currency - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + currency = meteredAllowance.currency + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -9165,29 +16577,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** An ISO 4217 currency string for which this price is billed in. */ fun currency(currency: String) = currency(JsonField.of(currency)) @@ -9210,7 +16599,22 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } /** * Sets the field to an arbitrary JSON value. @@ -9218,7 +16622,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -9568,6 +16972,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9610,30 +17035,27 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .currency() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("currency", currency), checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), modelType, checkRequired("name", name), billableMetricId, @@ -9646,6 +17068,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -9653,17 +17076,27 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() currency() itemId() + meteredAllowanceConfig().validate() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -9678,6 +17111,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -9699,12 +17133,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -9716,6 +17148,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -9838,6 +17271,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -9877,60 +17320,76 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), ) : this( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, mutableMapOf(), ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -9939,7 +17398,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -9948,24 +17407,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -9987,6 +17464,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -10003,12 +17500,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -10016,61 +17513,75 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) @@ -10085,7 +17596,9 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -10099,6 +17612,37 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10122,41 +17666,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -10176,30 +17734,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -10207,7 +17771,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } /** @@ -10277,6 +17841,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -10326,12 +17900,11 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && currency == other.currency && itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -10344,6 +17917,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -10351,9 +17925,9 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, currency, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -10366,6 +17940,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -10374,7 +17949,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MeteredAllowance{cadence=$cadence, currency=$currency, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class Percent @@ -10397,6 +17972,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -10454,6 +18030,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10474,6 +18053,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -10631,6 +18211,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10790,6 +18378,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10854,6 +18452,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10875,6 +18474,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata additionalProperties = percent.additionalProperties.toMutableMap() } @@ -11286,6 +18886,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11361,6 +18982,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -11368,6 +18990,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -11393,6 +19025,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -11429,6 +19062,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -11551,6 +19185,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -11718,6 +19362,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -11831,6 +19485,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -11897,6 +19561,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -11919,6 +19584,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -11927,7 +19593,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } class EventOutput @@ -11950,6 +19616,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -12007,6 +19674,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12027,6 +19697,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, mutableMapOf(), ) @@ -12185,6 +19856,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12344,6 +20023,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12408,6 +20097,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12429,6 +20119,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata additionalProperties = eventOutput.additionalProperties.toMutableMap() } @@ -12840,6 +20531,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -12915,6 +20627,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties.toMutableMap(), ) @@ -12922,6 +20635,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -12947,6 +20670,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } validated = true } @@ -12983,6 +20707,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) /** The cadence to bill for this price on. */ @@ -13105,6 +20830,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -13380,6 +21115,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -13505,6 +21250,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -13571,6 +21326,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && additionalProperties == other.additionalProperties } @@ -13593,6 +21349,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, additionalProperties, ) @@ -13601,7 +21358,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, currency=$currency, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, additionalProperties=$additionalProperties}" } } @@ -13620,6 +21377,7 @@ private constructor( filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && @@ -13638,6 +21396,7 @@ private constructor( filter, fixedFeeQuantityTransitions, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -13649,7 +21408,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Add{startDate=$startDate, allocationPrice=$allocationPrice, canDeferBilling=$canDeferBilling, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "Add{startDate=$startDate, allocationPrice=$allocationPrice, canDeferBilling=$canDeferBilling, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } class AddAdjustment @@ -14025,6 +21784,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AddAdjustment = apply { if (validated) { return@apply @@ -14089,6 +21857,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = startDate.accept(new StartDate.Visitor>() { + * @Override + * public Optional visitDateTime(OffsetDateTime dateTime) { + * return Optional.of(dateTime.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { dateTime != null -> visitor.visitDateTime(dateTime) @@ -14099,6 +21897,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StartDate = apply { if (validated) { return@apply @@ -14295,6 +22103,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentageDiscount != null -> @@ -14308,6 +22146,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -14546,6 +22394,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = endDate.accept(new EndDate.Visitor>() { + * @Override + * public Optional visitDateTime(OffsetDateTime dateTime) { + * return Optional.of(dateTime.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { dateTime != null -> visitor.visitDateTime(dateTime) @@ -14556,6 +22434,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EndDate = apply { if (validated) { return@apply @@ -14737,6 +22625,7 @@ private constructor( private val endDate: JsonField, private val filter: JsonField, private val fixedFeeQuantityTransitions: JsonField>, + private val metricParameterOverrides: JsonField, private val startDate: JsonField, private val usageCustomerIds: JsonField>, private val additionalProperties: MutableMap, @@ -14761,6 +22650,9 @@ private constructor( @ExcludeMissing fixedFeeQuantityTransitions: JsonField> = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing startDate: JsonField = JsonMissing.of(), @@ -14774,6 +22666,7 @@ private constructor( endDate, filter, fixedFeeQuantityTransitions, + metricParameterOverrides, startDate, usageCustomerIds, mutableMapOf(), @@ -14835,6 +22728,16 @@ private constructor( fun fixedFeeQuantityTransitions(): Optional> = fixedFeeQuantityTransitions.getOptional("fixed_fee_quantity_transitions") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * The updated start date of this price interval. If not specified, the start date will not * be updated. @@ -14912,6 +22815,17 @@ private constructor( fun _fixedFeeQuantityTransitions(): JsonField> = fixedFeeQuantityTransitions + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [startDate]. * @@ -14967,6 +22881,8 @@ private constructor( private var fixedFeeQuantityTransitions: JsonField>? = null + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var startDate: JsonField = JsonMissing.of() private var usageCustomerIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -14980,6 +22896,7 @@ private constructor( filter = edit.filter fixedFeeQuantityTransitions = edit.fixedFeeQuantityTransitions.map { it.toMutableList() } + metricParameterOverrides = edit.metricParameterOverrides startDate = edit.startDate usageCustomerIds = edit.usageCustomerIds.map { it.toMutableList() } additionalProperties = edit.additionalProperties.toMutableMap() @@ -15154,6 +23071,32 @@ private constructor( } } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values (number or string). + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * The updated start date of this price interval. If not specified, the start date will * not be updated. @@ -15258,6 +23201,7 @@ private constructor( endDate, filter, (fixedFeeQuantityTransitions ?: JsonMissing.of()).map { it.toImmutable() }, + metricParameterOverrides, startDate, (usageCustomerIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -15266,6 +23210,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Edit = apply { if (validated) { return@apply @@ -15277,6 +23230,7 @@ private constructor( endDate().ifPresent { it.validate() } filter() fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } + metricParameterOverrides().ifPresent { it.validate() } startDate().ifPresent { it.validate() } usageCustomerIds() validated = true @@ -15305,6 +23259,7 @@ private constructor( (if (filter.asKnown().isPresent) 1 else 0) + (fixedFeeQuantityTransitions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (startDate.asKnown().getOrNull()?.validity() ?: 0) + (usageCustomerIds.asKnown().getOrNull()?.size ?: 0) @@ -15337,6 +23292,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = endDate.accept(new EndDate.Visitor>() { + * @Override + * public Optional visitDateTime(OffsetDateTime dateTime) { + * return Optional.of(dateTime.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { dateTime != null -> visitor.visitDateTime(dateTime) @@ -15347,6 +23332,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EndDate = apply { if (validated) { return@apply @@ -15664,6 +23659,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): FixedFeeQuantityTransition = apply { if (validated) { return@apply @@ -15714,6 +23719,129 @@ private constructor( "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" } + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values (number or string). + */ + class MetricParameterOverrides + @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 + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** * The updated start date of this price interval. If not specified, the start date will not * be updated. @@ -15743,6 +23871,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = startDate.accept(new StartDate.Visitor>() { + * @Override + * public Optional visitDateTime(OffsetDateTime dateTime) { + * return Optional.of(dateTime.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { dateTime != null -> visitor.visitDateTime(dateTime) @@ -15753,6 +23911,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StartDate = apply { if (validated) { return@apply @@ -15914,6 +24082,7 @@ private constructor( endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && + metricParameterOverrides == other.metricParameterOverrides && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties @@ -15927,6 +24096,7 @@ private constructor( endDate, filter, fixedFeeQuantityTransitions, + metricParameterOverrides, startDate, usageCustomerIds, additionalProperties, @@ -15936,7 +24106,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Edit{priceIntervalId=$priceIntervalId, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "Edit{priceIntervalId=$priceIntervalId, billingCycleDay=$billingCycleDay, canDeferBilling=$canDeferBilling, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, metricParameterOverrides=$metricParameterOverrides, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } class EditAdjustment @@ -16165,6 +24335,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EditAdjustment = apply { if (validated) { return@apply @@ -16225,6 +24404,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = endDate.accept(new EndDate.Visitor>() { + * @Override + * public Optional visitDateTime(OffsetDateTime dateTime) { + * return Optional.of(dateTime.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { dateTime != null -> visitor.visitDateTime(dateTime) @@ -16235,6 +24444,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EndDate = apply { if (validated) { return@apply @@ -16413,6 +24632,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = startDate.accept(new StartDate.Visitor>() { + * @Override + * public Optional visitDateTime(OffsetDateTime dateTime) { + * return Optional.of(dateTime.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { dateTime != null -> visitor.visitDateTime(dateTime) @@ -16423,6 +24672,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): StartDate = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt index e248cd350..9682ddd5c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionRedeemCouponParams.kt @@ -747,6 +747,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -908,6 +917,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ChangeOption = apply { if (validated) { return@apply 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 937589fde..a2f2bc377 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 @@ -3113,6 +3113,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -3358,6 +3367,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ChangeOption = apply { if (validated) { return@apply @@ -3750,6 +3768,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AddAdjustment = apply { if (validated) { return@apply @@ -3830,6 +3857,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { percentageDiscount != null -> @@ -3843,6 +3900,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Adjustment = apply { if (validated) { return@apply @@ -4081,6 +4148,7 @@ private constructor( private val endDate: JsonField, private val externalPriceId: JsonField, private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, private val minimumAmount: JsonField, private val planPhaseOrder: JsonField, private val price: JsonField, @@ -4106,6 +4174,9 @@ private constructor( @JsonProperty("maximum_amount") @ExcludeMissing maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), @@ -4123,6 +4194,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -4176,6 +4248,16 @@ private constructor( @Deprecated("deprecated") fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -4269,6 +4351,17 @@ private constructor( @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + /** * Returns the raw JSON value of [minimumAmount]. * @@ -4339,6 +4432,8 @@ private constructor( private var endDate: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() private var planPhaseOrder: JsonField = JsonMissing.of() private var price: JsonField = JsonMissing.of() @@ -4353,6 +4448,7 @@ private constructor( endDate = addPrice.endDate externalPriceId = addPrice.externalPriceId maximumAmount = addPrice.maximumAmount + metricParameterOverrides = addPrice.metricParameterOverrides minimumAmount = addPrice.minimumAmount planPhaseOrder = addPrice.planPhaseOrder price = addPrice.price @@ -4480,6 +4576,32 @@ private constructor( this.maximumAmount = maximumAmount } + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. @@ -4607,6 +4729,13 @@ private constructor( fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ @@ -4696,6 +4825,16 @@ private constructor( fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ fun price(minimumComposite: NewSubscriptionMinimumCompositePrice) = price(Price.ofMinimumComposite(minimumComposite)) @@ -4773,6 +4912,7 @@ private constructor( endDate, externalPriceId, maximumAmount, + metricParameterOverrides, minimumAmount, planPhaseOrder, price, @@ -4784,6 +4924,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): AddPrice = apply { if (validated) { return@apply @@ -4794,6 +4943,7 @@ private constructor( endDate() externalPriceId() maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } minimumAmount() planPhaseOrder() price().ifPresent { it.validate() } @@ -4823,12 +4973,136 @@ private constructor( (if (endDate.asKnown().isPresent) 1 else 0) + (if (externalPriceId.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (price.asKnown().getOrNull()?.validity() ?: 0) + (if (priceId.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @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 + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + /** New subscription price request body params. */ @JsonDeserialize(using = Price.Deserializer::class) @JsonSerialize(using = Price.Serializer::class) @@ -4849,6 +5123,7 @@ private constructor( private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, private val tieredWithProration: TieredWithProration? = null, private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, @@ -4870,6 +5145,8 @@ private constructor( null, private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, private val minimumComposite: NewSubscriptionMinimumCompositePrice? = null, private val percent: Percent? = null, private val eventOutput: EventOutput? = null, @@ -4912,6 +5189,9 @@ private constructor( fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) @@ -4958,6 +5238,12 @@ private constructor( fun cumulativeGroupedAllocation(): Optional = Optional.ofNullable(cumulativeGroupedAllocation) + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + fun minimumComposite(): Optional = Optional.ofNullable(minimumComposite) @@ -4993,6 +5279,8 @@ private constructor( fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + fun isTieredWithProration(): Boolean = tieredWithProration != null fun isUnitWithProration(): Boolean = unitWithProration != null @@ -5022,6 +5310,10 @@ private constructor( fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + fun isMinimumComposite(): Boolean = minimumComposite != null fun isPercent(): Boolean = percent != null @@ -5064,6 +5356,9 @@ private constructor( fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = matrixWithAllocation.getOrThrow("matrixWithAllocation") + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") @@ -5108,6 +5403,12 @@ private constructor( fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + fun asMinimumComposite(): NewSubscriptionMinimumCompositePrice = minimumComposite.getOrThrow("minimumComposite") @@ -5117,6 +5418,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewSubscriptionUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) @@ -5137,6 +5468,8 @@ private constructor( unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) matrixWithAllocation != null -> visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) @@ -5164,6 +5497,9 @@ private constructor( visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) cumulativeGroupedAllocation != null -> visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) percent != null -> visitor.visitPercent(percent) eventOutput != null -> visitor.visitEventOutput(eventOutput) @@ -5172,6 +5508,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Price = apply { if (validated) { return@apply @@ -5251,6 +5597,12 @@ private constructor( matrixWithAllocation.validate() } + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) { @@ -5338,6 +5690,16 @@ private constructor( cumulativeGroupedAllocation.validate() } + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + override fun visitMinimumComposite( minimumComposite: NewSubscriptionMinimumCompositePrice ) { @@ -5422,6 +5784,10 @@ private constructor( matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice ) = matrixWithAllocation.validity() + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + override fun visitTieredWithProration( tieredWithProration: TieredWithProration ) = tieredWithProration.validity() @@ -5481,6 +5847,13 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = cumulativeGroupedAllocation.validity() + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + override fun visitMinimumComposite( minimumComposite: NewSubscriptionMinimumCompositePrice ) = minimumComposite.validity() @@ -5514,6 +5887,7 @@ private constructor( packageWithAllocation == other.packageWithAllocation && unitWithPercent == other.unitWithPercent && matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && tieredWithProration == other.tieredWithProration && unitWithProration == other.unitWithProration && groupedAllocation == other.groupedAllocation && @@ -5528,6 +5902,8 @@ private constructor( scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && cumulativeGroupedBulk == other.cumulativeGroupedBulk && cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && minimumComposite == other.minimumComposite && percent == other.percent && eventOutput == other.eventOutput @@ -5549,6 +5925,7 @@ private constructor( packageWithAllocation, unitWithPercent, matrixWithAllocation, + matrixWithThresholdDiscounts, tieredWithProration, unitWithProration, groupedAllocation, @@ -5563,6 +5940,8 @@ private constructor( scalableMatrixWithTieredPricing, cumulativeGroupedBulk, cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, minimumComposite, percent, eventOutput, @@ -5588,6 +5967,8 @@ private constructor( unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" matrixWithAllocation != null -> "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" @@ -5612,6 +5993,9 @@ private constructor( "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" cumulativeGroupedAllocation != null -> "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" percent != null -> "Price{percent=$percent}" eventOutput != null -> "Price{eventOutput=$eventOutput}" @@ -5672,6 +6056,11 @@ private constructor( matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice ) = Price(matrixWithAllocation = matrixWithAllocation) + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + @JvmStatic fun ofTieredWithProration(tieredWithProration: TieredWithProration) = Price(tieredWithProration = tieredWithProration) @@ -5739,6 +6128,14 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + @JvmStatic fun ofMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice) = Price(minimumComposite = minimumComposite) @@ -5792,6 +6189,10 @@ private constructor( matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice ): T + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T fun visitUnitWithProration( @@ -5847,6 +6248,10 @@ private constructor( cumulativeGroupedAllocation: CumulativeGroupedAllocation ): T + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + fun visitMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice): T fun visitPercent(percent: Percent): T @@ -5974,6 +6379,14 @@ private constructor( ?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } "tiered_with_proration" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(tieredWithProration = it, _json = json) } @@ -6087,6 +6500,16 @@ private constructor( ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } ?: Price(_json = json) } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } "minimum_composite" -> { return tryDeserialize( node, @@ -6140,6 +6563,8 @@ private constructor( generator.writeObject(value.unitWithPercent) value.matrixWithAllocation != null -> generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) value.tieredWithProration != null -> generator.writeObject(value.tieredWithProration) value.unitWithProration != null -> @@ -6168,6 +6593,10 @@ private constructor( generator.writeObject(value.cumulativeGroupedBulk) value.cumulativeGroupedAllocation != null -> generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) value.minimumComposite != null -> generator.writeObject(value.minimumComposite) value.percent != null -> generator.writeObject(value.percent) @@ -6198,6 +6627,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -6256,6 +6686,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -6279,6 +6712,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -6438,6 +6872,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -6607,6 +7049,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -6680,6 +7132,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -6703,6 +7156,7 @@ private constructor( fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId metadata = bulkWithFilters.metadata referenceId = bulkWithFilters.referenceId additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() @@ -7121,6 +7575,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -7217,6 +7692,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -7225,6 +7701,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): BulkWithFilters = apply { if (validated) { return@apply @@ -7250,6 +7736,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -7287,6 +7774,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -7489,6 +7977,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): BulkWithFiltersConfig = apply { if (validated) { return@apply @@ -7692,6 +8190,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -7921,6 +8429,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Tier = apply { if (validated) { return@apply @@ -8112,6 +8630,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -8218,6 +8746,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -8284,6 +8822,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -8307,6 +8846,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -8316,17 +8856,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class MatrixWithThresholdDiscounts @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -8339,6 +8880,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -8352,16 +8894,17 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -8398,6 +8941,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -8407,9 +8953,9 @@ private constructor( ) : this( cadence, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -8421,6 +8967,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -8444,12 +8991,24 @@ private constructor( */ fun itemId(): String = itemId.getRequired("item_id") + /** + * Configuration for matrix_with_threshold_discounts pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) + /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -8466,16 +9025,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -8580,6 +9129,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -8618,23 +9175,24 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig /** - * Returns the raw JSON value of [tieredWithProrationConfig]. + * Returns the raw JSON value of [name]. * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [billableMetricId]. @@ -8749,6 +9307,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -8785,28 +9353,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [MatrixWithThresholdDiscounts]. * * The following fields are required: * ```java * .cadence() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [MatrixWithThresholdDiscounts]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = + private var matrixWithThresholdDiscountsConfig: + JsonField? = null + private var modelType: JsonValue = + JsonValue.from("matrix_with_threshold_discounts") + private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -8824,35 +9394,40 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = + apply { + cadence = matrixWithThresholdDiscounts.cadence + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance + billingCycleConfiguration = + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + currency = matrixWithThresholdDiscounts.currency + dimensionalPriceConfiguration = + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata + referenceId = matrixWithThresholdDiscounts.referenceId + additionalProperties = + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -8878,13 +9453,36 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + /** * Sets the field to an arbitrary JSON value. * * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("matrix_with_threshold_discounts") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -8904,22 +9502,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -9268,6 +9850,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -9332,7 +9935,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -9340,19 +9943,22 @@ private constructor( * ```java * .cadence() * .itemId() + * .matrixWithThresholdDiscountsConfig() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired( + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, + ), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -9364,6 +9970,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -9372,20 +9979,30 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { if (validated) { return@apply } cadence().validate() itemId() + matrixWithThresholdDiscountsConfig().validate() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -9397,6 +10014,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -9420,11 +10038,12 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -9436,6 +10055,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -9559,6 +10179,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -9598,40 +10228,140 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("default_unit_amount") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * Unit price used for usage that does not match any defined matrix cell. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * Returns the raw JSON value of [tiers]. + * First matrix dimension key. * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Per-cell unit prices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Optional second matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -9649,58 +10379,165 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [MatrixWithThresholdDiscountsConfig]. * * The following fields are required: * ```java - * .tiers() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = apply { + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } + additionalProperties = + matrixWithThresholdDiscountsConfig.additionalProperties + .toMutableMap() + } /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Unit price used for usage that does not match any defined matrix cell. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. * * @throws IllegalStateException if the field was previously set to a * non-list. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) } } @@ -9727,32 +10564,56 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } validated = true } @@ -9772,40 +10633,51 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tierLowerBound: JsonField, + private val firstDimensionValue: JsonField, private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tier_lower_bound") + @JsonProperty("first_dimension_value") @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), + firstDimensionValue: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + mutableMapOf(), + ) /** - * Inclusive tier starting value - * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") + fun firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") /** - * Amount per unit - * * @throws OrbInvalidDataException if the JSON field has an unexpected type * or is unexpectedly missing or null (e.g. if the server responded with * an unexpected value). @@ -9813,14 +10685,21 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [tierLowerBound]. + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("tier_lower_bound") + @JsonProperty("first_dimension_value") @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + fun _firstDimensionValue(): JsonField = firstDimensionValue /** * Returns the raw JSON value of [unitAmount]. @@ -9832,6 +10711,16 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -9847,48 +10736,51 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Tier]. + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. * * The following fields are required: * ```java - * .tierLowerBound() + * .firstDimensionValue() * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Tier]. */ + /** A builder for [MatrixValue]. */ class Builder internal constructor() { - private var tierLowerBound: JsonField? = null + private var firstDimensionValue: JsonField? = null private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() } - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } - /** Amount per unit */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) @@ -9903,6 +10795,28 @@ private constructor( this.unitAmount = unitAmount } + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -9926,36 +10840,48 @@ private constructor( } /** - * Returns an immutable instance of [Tier]. + * Returns an immutable instance of [MatrixValue]. * * Further updates to this [Builder] will not mutate the returned * instance. * * The following fields are required: * ```java - * .tierLowerBound() + * .firstDimensionValue() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), checkRequired("unitAmount", unitAmount), + secondDimensionValue, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Tier = apply { + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { if (validated) { return@apply } - tierLowerBound() + firstDimensionValue() unitAmount() + secondDimensionValue() validated = true } @@ -9975,28 +10901,470 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Tier && - tierLowerBound == other.tierLowerBound && + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -10004,17 +11372,30 @@ private constructor( return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" } /** @@ -10084,6 +11465,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -10133,12 +11524,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is MatrixWithThresholdDiscounts && cadence == other.cadence && itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -10150,6 +11542,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -10159,9 +11552,9 @@ private constructor( Objects.hash( cadence, itemId, + matrixWithThresholdDiscountsConfig, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10173,6 +11566,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -10182,18 +11576,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MatrixWithThresholdDiscounts{cadence=$cadence, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class TieredWithProration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, + private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -10206,6 +11599,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -10216,11 +11610,6 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -10230,6 +11619,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -10266,6 +11659,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -10274,10 +11670,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -10289,6 +11685,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -10303,18 +11700,6 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Configuration for grouped_with_min_max_thresholds pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) - /** * The id of the item the price will be associated with. * @@ -10329,7 +11714,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -10346,6 +11731,16 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -10450,6 +11845,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -10479,17 +11882,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. - * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("grouped_with_min_max_thresholds_config") - @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig - /** * Returns the raw JSON value of [itemId]. * @@ -10506,6 +11898,17 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + /** * Returns the raw JSON value of [billableMetricId]. * @@ -10619,6 +12022,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -10655,30 +12068,28 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [TieredWithProration]. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -10696,38 +12107,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -10741,29 +12151,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) - - /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -10782,7 +12169,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("tiered_with_proration") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -10802,6 +12189,22 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -11150,6 +12553,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -11214,30 +12638,27 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() + * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11249,6 +12670,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -11257,20 +12679,30 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("tiered_with_proration")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() + tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -11282,6 +12714,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -11304,12 +12737,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -11321,6 +12754,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -11444,6 +12878,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -11483,108 +12927,40 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val tiers: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") - @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") - @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") - @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + @JsonProperty("tiers") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) - - /** - * The event property used to group before applying thresholds - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") - - /** - * The maximum amount to charge each group - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") - - /** - * The minimum amount to charge each group, regardless of usage - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) /** - * The base price charged per group + * Tiers for rating based on total usage quantities into the specified tier with + * proration * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") - - /** - * Returns the raw JSON value of [groupingKey]. - * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("grouping_key") - @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey - - /** - * Returns the raw JSON value of [maximumCharge]. - * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maximum_charge") - @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge - - /** - * Returns the raw JSON value of [minimumCharge]. - * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minimum_charge") - @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun tiers(): List = tiers.getRequired("tiers") /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [tiers]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("tiers") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _tiers(): JsonField> = tiers @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -11602,100 +12978,59 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [TieredWithProrationConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .tiers() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [TieredWithProrationConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } - - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) - - /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * Tiers for rating based on total usage quantities into the specified tier + * with proration */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge - } - - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.tiers] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) - /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Adds a single [Tier] to [tiers]. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -11721,41 +13056,42 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [TieredWithProrationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .tiers() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): TieredWithProrationConfig = apply { if (validated) { return@apply } - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() + tiers().forEach { it.validate() } validated = true } @@ -11775,38 +13111,259 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) + + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && + return other is TieredWithProrationConfig && + tiers == other.tiers && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) - } + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" } /** @@ -11876,6 +13433,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -11925,13 +13492,12 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is TieredWithProration && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -11943,6 +13509,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -11951,10 +13518,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, itemId, modelType, name, + tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -11966,6 +13533,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -11975,15 +13543,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class GroupedWithMinMaxThresholds @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -11999,6 +13567,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -12009,10 +13578,10 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = + groupedWithMinMaxThresholdsConfig: + JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -12059,6 +13628,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -12067,7 +13639,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -12082,6 +13654,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -12097,15 +13670,15 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * Configuration for grouped_with_min_max_thresholds pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" ) /** @@ -12122,7 +13695,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -12243,6 +13816,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -12273,15 +13854,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON * field has an unexpected type. */ - @JsonProperty("cumulative_grouped_allocation_config") + @JsonProperty("grouped_with_min_max_thresholds_config") @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig /** * Returns the raw JSON value of [itemId]. @@ -12412,6 +13993,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -12448,12 +14039,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * [GroupedWithMinMaxThresholds]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() * ``` @@ -12461,16 +14052,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [GroupedWithMinMaxThresholds]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = + private var groupedWithMinMaxThresholdsConfig: + JsonField? = null private var itemId: JsonField? = null private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + JsonValue.from("grouped_with_min_max_thresholds") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -12489,37 +14080,39 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -12534,27 +14127,27 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) ) /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig } /** The id of the item the price will be associated with. */ @@ -12575,7 +14168,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("grouped_with_min_max_thresholds") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -12943,6 +14536,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -13007,26 +14621,26 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() + * .groupedWithMinMaxThresholdsConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( checkRequired("cadence", cadence), checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, ), checkRequired("itemId", itemId), modelType, @@ -13042,6 +14656,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -13050,16 +14665,26 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() + groupedWithMinMaxThresholdsConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -13075,6 +14700,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -13097,10 +14723,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -13114,6 +14740,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -13237,6 +14864,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -13276,115 +14913,108 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, private val groupingKey: JsonField, - private val unitAmount: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") - @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") - @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") + @JsonProperty("maximum_charge") @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this( - cumulativeAllocation, - groupAllocation, - groupingKey, - unitAmount, - mutableMapOf(), - ) + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) /** - * The overall allocation across all groups + * The event property used to group before applying thresholds * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The allocation per individual group + * The maximum amount to charge each group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") /** - * The event property used to group usage before applying allocations + * The minimum amount to charge each group, regardless of usage * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") /** - * The amount to charge for each unit outside of the allocation + * The base price charged per group * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Returns the raw JSON value of [groupingKey]. * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field - * has an unexpected type. + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("grouping_key") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _groupingKey(): JsonField = groupingKey /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [maximumCharge]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("maximum_charge") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _maximumCharge(): JsonField = maximumCharge /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [minimumCharge]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("minimum_charge") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _minimumCharge(): JsonField = minimumCharge /** - * Returns the raw JSON value of [unitAmount]. + * Returns the raw JSON value of [perUnitRate]. * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_amount") + @JsonProperty("per_unit_rate") @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun _perUnitRate(): JsonField = perUnitRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -13402,100 +15032,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [GroupedWithMinMaxThresholdsConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() * .groupingKey() - * .unitAmount() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null private var groupingKey: JsonField? = null - private var unitAmount: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties + groupedWithMinMaxThresholdsConfig.additionalProperties .toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.groupingKey] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.maximumCharge] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed + * You should usually call [Builder.maximumCharge] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge } - /** The event property used to group usage before applying allocations */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.minimumCharge] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge } - /** The amount to charge for each unit outside of the allocation */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. + * Sets [Builder.perUnitRate] to an arbitrary JSON value. * - * You should usually call [Builder.unitAmount] with a well-typed [String] + * You should usually call [Builder.perUnitRate] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate } fun additionalProperties(additionalProperties: Map) = @@ -13521,41 +15151,51 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() * .groupingKey() - * .unitAmount() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( checkRequired("groupingKey", groupingKey), - checkRequired("unitAmount", unitAmount), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() groupingKey() - unitAmount() + maximumCharge() + minimumCharge() + perUnitRate() validated = true } @@ -13575,30 +15215,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is GroupedWithMinMaxThresholdsConfig && groupingKey == other.groupingKey && - unitAmount == other.unitAmount && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, groupingKey, - unitAmount, + maximumCharge, + minimumCharge, + perUnitRate, additionalProperties, ) } @@ -13606,7 +15246,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" } /** @@ -13676,6 +15316,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -13725,10 +15375,10 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -13743,6 +15393,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -13751,7 +15402,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -13766,6 +15417,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -13775,17 +15427,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class Percent + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val percentConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -13798,6 +15451,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -13808,6 +15462,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -13817,9 +15476,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("percent_config") - @ExcludeMissing - percentConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -13856,6 +15512,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -13864,10 +15523,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -13879,6 +15538,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -13893,6 +15553,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -13907,7 +15579,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -13924,15 +15596,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for percent pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -14037,6 +15700,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -14066,6 +15737,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -14082,16 +15764,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [percentConfig]. - * - * Unlike [percentConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percent_config") - @ExcludeMissing - fun _percentConfig(): JsonField = percentConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -14205,6 +15877,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -14240,27 +15922,31 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Percent]. + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Percent]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("percent") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var percentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -14278,32 +15964,40 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percent: Percent) = apply { - cadence = percent.cadence - itemId = percent.itemId - modelType = percent.modelType - name = percent.name - percentConfig = percent.percentConfig - billableMetricId = percent.billableMetricId - billedInAdvance = percent.billedInAdvance - billingCycleConfiguration = percent.billingCycleConfiguration - conversionRate = percent.conversionRate - conversionRateConfig = percent.conversionRateConfig - currency = percent.currency - dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration - externalPriceId = percent.externalPriceId - fixedPriceQuantity = percent.fixedPriceQuantity - invoiceGroupingKey = percent.invoiceGroupingKey - invoicingCycleConfiguration = percent.invoicingCycleConfiguration - metadata = percent.metadata - referenceId = percent.referenceId - additionalProperties = percent.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -14317,6 +16011,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -14335,7 +16052,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("percent") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -14355,21 +16072,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for percent pricing */ - fun percentConfig(percentConfig: PercentConfig) = - percentConfig(JsonField.of(percentConfig)) - - /** - * Sets [Builder.percentConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.percentConfig] with a well-typed - * [PercentConfig] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun percentConfig(percentConfig: JsonField) = apply { - this.percentConfig = percentConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -14718,6 +16420,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -14782,27 +16505,30 @@ private constructor( } /** - * Returns an immutable instance of [Percent]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .percentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Percent = - Percent( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("percentConfig", percentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -14814,6 +16540,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -14822,20 +16549,30 @@ private constructor( private var validated: Boolean = false - fun validate(): Percent = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("percent")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - percentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -14847,6 +16584,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -14869,10 +16607,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + - (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -14884,6 +16624,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -15007,6 +16748,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -15046,39 +16797,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for percent pricing */ - class PercentConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val percent: JsonField, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("percent") + @JsonProperty("cumulative_allocation") @ExcludeMissing - percent: JsonField = JsonMissing.of() - ) : this(percent, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * What percent of the component subtotals to charge + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun percent(): Double = percent.getRequired("percent") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [percent]. + * The allocation per individual group * - * Unlike [percent], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") + @ExcludeMissing + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("percent") + @JsonProperty("group_allocation") @ExcludeMissing - fun _percent(): JsonField = percent + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -15096,40 +16923,101 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PercentConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```java - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [PercentConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var percent: JsonField? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentConfig: PercentConfig) = apply { - percent = percentConfig.percent - additionalProperties = percentConfig.additionalProperties.toMutableMap() + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() } - /** What percent of the component subtotals to charge */ - fun percent(percent: Double) = percent(JsonField.of(percent)) + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Sets [Builder.percent] to an arbitrary JSON value. + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.percent] with a well-typed [Double] + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) + + /** + * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun percent(percent: JsonField) = apply { this.percent = percent } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -15154,32 +17042,51 @@ private constructor( } /** - * Returns an immutable instance of [PercentConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .percent() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentConfig = - PercentConfig( - checkRequired("percent", percent), + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): PercentConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - percent() + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -15198,26 +17105,39 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is PercentConfig && - percent == other.percent && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(percent, additionalProperties) + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -15287,6 +17207,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -15336,12 +17266,13 @@ private constructor( return true } - return other is Percent && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - percentConfig == other.percentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -15353,6 +17284,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -15361,10 +17293,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - percentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -15376,6 +17308,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -15385,14 +17318,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class EventOutput + class DailyCreditAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val eventOutputConfig: JsonField, + private val dailyCreditAllowanceConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -15408,6 +17341,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -15418,9 +17352,10 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("event_output_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - eventOutputConfig: JsonField = JsonMissing.of(), + dailyCreditAllowanceConfig: JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -15466,6 +17401,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -15474,7 +17412,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - eventOutputConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -15489,6 +17427,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -15504,14 +17443,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for event_output pricing + * Configuration for daily_credit_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun eventOutputConfig(): EventOutputConfig = - eventOutputConfig.getRequired("event_output_config") + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") /** * The id of the item the price will be associated with. @@ -15527,7 +17466,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("daily_credit_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -15648,6 +17587,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -15678,14 +17625,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [eventOutputConfig]. + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. * - * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("event_output_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - fun _eventOutputConfig(): JsonField = eventOutputConfig + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig /** * Returns the raw JSON value of [itemId]. @@ -15816,6 +17764,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -15851,12 +17809,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EventOutput]. + * Returns a mutable builder for constructing an instance of + * [DailyCreditAllowance]. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` @@ -15864,13 +17823,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutput]. */ + /** A builder for [DailyCreditAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var eventOutputConfig: JsonField? = null + private var dailyCreditAllowanceConfig: JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("event_output") + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -15889,31 +17849,36 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutput: EventOutput) = apply { - cadence = eventOutput.cadence - eventOutputConfig = eventOutput.eventOutputConfig - itemId = eventOutput.itemId - modelType = eventOutput.modelType - name = eventOutput.name - billableMetricId = eventOutput.billableMetricId - billedInAdvance = eventOutput.billedInAdvance - billingCycleConfiguration = eventOutput.billingCycleConfiguration - conversionRate = eventOutput.conversionRate - conversionRateConfig = eventOutput.conversionRateConfig - currency = eventOutput.currency - dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration - externalPriceId = eventOutput.externalPriceId - fixedPriceQuantity = eventOutput.fixedPriceQuantity - invoiceGroupingKey = eventOutput.invoiceGroupingKey - invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration - metadata = eventOutput.metadata - referenceId = eventOutput.referenceId - additionalProperties = eventOutput.additionalProperties.toMutableMap() + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + currency = dailyCreditAllowance.currency + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + referenceId = dailyCreditAllowance.referenceId + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -15928,20 +17893,22 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for event_output pricing */ - fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = - eventOutputConfig(JsonField.of(eventOutputConfig)) + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) /** - * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. * - * You should usually call [Builder.eventOutputConfig] with a well-typed - * [EventOutputConfig] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. */ - fun eventOutputConfig(eventOutputConfig: JsonField) = apply { - this.eventOutputConfig = eventOutputConfig - } + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -15961,7 +17928,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("event_output") + * JsonValue.from("daily_credit_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -16329,6 +18296,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -16393,24 +18381,24 @@ private constructor( } /** - * Returns an immutable instance of [EventOutput]. + * Returns an immutable instance of [DailyCreditAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .eventOutputConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): EventOutput = - EventOutput( + fun build(): DailyCreditAllowance = + DailyCreditAllowance( checkRequired("cadence", cadence), - checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -16425,6 +18413,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -16433,16 +18422,26 @@ private constructor( private var validated: Boolean = false - fun validate(): EventOutput = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { if (validated) { return@apply } cadence().validate() - eventOutputConfig().validate() + dailyCreditAllowanceConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("event_output")) { + if (it != JsonValue.from("daily_credit_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -16458,6 +18457,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -16480,9 +18480,11 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + modelType.let { + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -16495,6 +18497,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -16618,6 +18621,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -16657,87 +18670,144 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for event_output pricing */ - class EventOutputConfig + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val unitRatingKey: JsonField, - private val defaultUnitRate: JsonField, - private val groupingKey: JsonField, + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("unit_rating_key") + @JsonProperty("daily_allowance") @ExcludeMissing - unitRatingKey: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_rate") + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") @ExcludeMissing - defaultUnitRate: JsonField = JsonMissing.of(), - @JsonProperty("grouping_key") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") + @ExcludeMissing + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) /** - * The key in the event data to extract the unit rate from. + * Credits granted per day. Lose-it-or-use-it; does not roll over. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") /** - * If provided, this amount will be used as the unit rate when an event does not - * have a value for the `unit_rating_key`. If not provided, events missing a - * unit rate will be ignored. + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun defaultUnitRate(): Optional = - defaultUnitRate.getOptional("default_unit_rate") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * An optional key in the event data to group by (e.g., event ID). All events - * will also be grouped by their unit rate. + * One or two event property values to evaluate matrix groups by * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + fun dimensions(): List = dimensions.getRequired("dimensions") /** - * Returns the raw JSON value of [unitRatingKey]. + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. * - * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") + + /** + * Per-dimension credit rates + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("unit_rating_key") + @JsonProperty("daily_allowance") @ExcludeMissing - fun _unitRatingKey(): JsonField = unitRatingKey + fun _dailyAllowance(): JsonField = dailyAllowance /** - * Returns the raw JSON value of [defaultUnitRate]. + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("default_unit_rate") + @JsonProperty("dimensions") @ExcludeMissing - fun _defaultUnitRate(): JsonField = defaultUnitRate + fun _dimensions(): JsonField> = dimensions /** - * Returns the raw JSON value of [groupingKey]. + * Returns the raw JSON value of [eventDayProperty]. * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("event_day_property") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _eventDayProperty(): JsonField = eventDayProperty + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -16755,235 +18825,583 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [EventOutputConfig]. + * [DailyCreditAllowanceConfig]. * * The following fields are required: * ```java - * .unitRatingKey() + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [EventOutputConfig]. */ + /** A builder for [DailyCreditAllowanceConfig]. */ class Builder internal constructor() { - private var unitRatingKey: JsonField? = null - private var defaultUnitRate: JsonField = JsonMissing.of() - private var groupingKey: JsonField = JsonMissing.of() + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventOutputConfig: EventOutputConfig) = apply { - unitRatingKey = eventOutputConfig.unitRatingKey - defaultUnitRate = eventOutputConfig.defaultUnitRate - groupingKey = eventOutputConfig.groupingKey - additionalProperties = - eventOutputConfig.additionalProperties.toMutableMap() - } + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } - /** The key in the event data to extract the unit rate from. */ - fun unitRatingKey(unitRatingKey: String) = - unitRatingKey(JsonField.of(unitRatingKey)) + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) /** - * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. * - * You should usually call [Builder.unitRatingKey] with a well-typed + * You should usually call [Builder.dailyAllowance] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun unitRatingKey(unitRatingKey: JsonField) = apply { - this.unitRatingKey = unitRatingKey + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance } /** - * If provided, this amount will be used as the unit rate when an event does - * not have a value for the `unit_rating_key`. If not provided, events - * missing a unit rate will be ignored. - */ - fun defaultUnitRate(defaultUnitRate: String?) = - defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) - - /** - * Alias for calling [Builder.defaultUnitRate] with - * `defaultUnitRate.orElse(null)`. + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value */ - fun defaultUnitRate(defaultUnitRate: Optional) = - defaultUnitRate(defaultUnitRate.getOrNull()) + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.defaultUnitRate] with a well-typed + * You should usually call [Builder.defaultUnitAmount] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun defaultUnitRate(defaultUnitRate: JsonField) = apply { - this.defaultUnitRate = defaultUnitRate + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** - * An optional key in the event data to group by (e.g., event ID). All - * events will also be grouped by their unit rate. - */ - fun groupingKey(groupingKey: String?) = - groupingKey(JsonField.ofNullable(groupingKey)) + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) /** - * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + * Sets [Builder.dimensions] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: Optional) = - groupingKey(groupingKey.getOrNull()) + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Adds a single [String] to [dimensions]. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws IllegalStateException if the field was previously set to a + * non-list. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) /** - * Returns an immutable instance of [EventOutputConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .unitRatingKey() - * ``` + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. * - * @throws IllegalStateException if any required field is unset. + * You should usually call [Builder.eventDayProperty] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun build(): EventOutputConfig = - EventOutputConfig( - checkRequired("unitRatingKey", unitRatingKey), - defaultUnitRate, - groupingKey, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EventOutputConfig = apply { - if (validated) { - return@apply + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty } - unitRatingKey() - defaultUnitRate() - groupingKey() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (unitRatingKey.asKnown().isPresent) 1 else 0) + - (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + - (if (groupingKey.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } - return other is EventOutputConfig && - unitRatingKey == other.unitRatingKey && - defaultUnitRate == other.defaultUnitRate && - groupingKey == other.groupingKey && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - unitRatingKey, - defaultUnitRate, - groupingKey, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + dimensionValues() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -17018,6 +19436,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -17067,9 +19495,9 @@ private constructor( return true } - return other is EventOutput && + return other is DailyCreditAllowance && cadence == other.cadence && - eventOutputConfig == other.eventOutputConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -17084,6 +19512,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -17092,7 +19521,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - eventOutputConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -17107,6 +19536,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -17116,5012 +19546,17272 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddPrice && - allocationPrice == other.allocationPrice && - discounts == other.discounts && - endDate == other.endDate && - externalPriceId == other.externalPriceId && - maximumAmount == other.maximumAmount && - minimumAmount == other.minimumAmount && - planPhaseOrder == other.planPhaseOrder && - price == other.price && - priceId == other.priceId && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - allocationPrice, - discounts, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties, - ) - } - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } + class MeteredAllowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Reset billing periods to be aligned with the plan change's effective date or start of the - * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. - */ - class BillingCycleAlignment - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + meteredAllowanceConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - companion object { + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - @JvmField val UNCHANGED = of("unchanged") + /** + * Configuration for metered_allowance pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") - @JvmField val PLAN_CHANGE_DATE = of("plan_change_date") + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("metered_allowance") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - @JvmField val START_OF_MONTH = of("start_of_month") + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - @JvmStatic fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** An enum containing [BillingCycleAlignment]'s known values. */ - enum class Known { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** - * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - /** - * An enum member indicating that [BillingCycleAlignment] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNCHANGED -> Value.UNCHANGED - PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE - START_OF_MONTH -> Value.START_OF_MONTH - else -> Value._UNKNOWN - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - UNCHANGED -> Known.UNCHANGED - PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE - START_OF_MONTH -> Known.START_OF_MONTH - else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") - } + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - private var validated: Boolean = false + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - fun validate(): BillingCycleAlignment = apply { - if (validated) { - return@apply - } + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - known() - validated = true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - return other is BillingCycleAlignment && value == other.value - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - override fun hashCode() = value.hashCode() + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - override fun toString() = value.toString() - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - class RemoveAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - adjustmentId: JsonField = JsonMissing.of() - ) : this(adjustmentId, mutableMapOf()) + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig - /** - * The id of the adjustment to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [adjustmentId]. - * - * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun toBuilder() = Builder().from(this) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - companion object { + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** A builder for [RemoveAdjustment]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - private var adjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - @JvmSynthetic - internal fun from(removeAdjustment: RemoveAdjustment) = apply { - adjustmentId = removeAdjustment.adjustmentId - additionalProperties = removeAdjustment.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Sets [Builder.adjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustmentId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustmentId(adjustmentId: JsonField) = apply { - this.adjustmentId = adjustmentId - } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns an immutable instance of [RemoveAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toMutableMap(), - ) - } + fun toBuilder() = Builder().from(this) - private var validated: Boolean = false + companion object { - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .meteredAllowanceConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - adjustmentId() - validated = true - } + /** A builder for [MeteredAllowance]. */ + class Builder internal constructor() { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + currency = meteredAllowance.currency + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + referenceId = meteredAllowance.referenceId + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - return other is RemoveAdjustment && - adjustmentId == other.adjustmentId && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) - class RemovePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val externalPriceId: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this(externalPriceId, priceId, mutableMapOf()) + /** + * Sets 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("metered_allowance") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * The external price id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * The id of the price to remove on the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): Optional = priceId.getOptional("price_id") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - companion object { + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** A builder for [RemovePrice]. */ - class Builder internal constructor() { + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - private var externalPriceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - @JvmSynthetic - internal fun from(removePrice: RemovePrice) = apply { - externalPriceId = removePrice.externalPriceId - priceId = removePrice.priceId - additionalProperties = removePrice.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ - fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - /** - * Returns an immutable instance of [RemovePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - private var validated: Boolean = false + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - externalPriceId() - priceId() - validated = true - } + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (priceId.asKnown().isPresent) 1 else 0) + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - return other is RemovePrice && - externalPriceId == other.externalPriceId && - priceId == other.priceId && - additionalProperties == other.additionalProperties - } + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - private val hashCode: Int by lazy { - Objects.hash(externalPriceId, priceId, additionalProperties) - } + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - class ReplaceAdjustment - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adjustment: JsonField, - private val replacesAdjustmentId: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - replacesAdjustmentId: JsonField = JsonMissing.of(), - ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) - - /** - * The definition of a new adjustment to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** - * The id of the adjustment on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") - - /** - * Returns the raw JSON value of [adjustment]. - * - * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** - * Returns the raw JSON value of [replacesAdjustmentId]. - * - * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - companion object { + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** A builder for [ReplaceAdjustment]. */ - class Builder internal constructor() { + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - private var adjustment: JsonField? = null - private var replacesAdjustmentId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - @JvmSynthetic - internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { - adjustment = replaceAdjustment.adjustment - replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId - additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Sets [Builder.adjustment] to an arbitrary JSON value. - * - * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPercentageDiscount(percentageDiscount)`. - */ - fun adjustment(percentageDiscount: NewPercentageDiscount) = - adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewPercentageDiscount.builder() - * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - * .percentageDiscount(percentageDiscount) - * .build() - * ``` - */ - fun percentageDiscountAdjustment(percentageDiscount: Double) = - adjustment( - NewPercentageDiscount.builder() - .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) - .percentageDiscount(percentageDiscount) - .build() - ) + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment(usageDiscount: NewUsageDiscount) = - adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewUsageDiscount.builder() - * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - * .usageDiscount(usageDiscount) - * .build() - * ``` - */ - fun usageDiscountAdjustment(usageDiscount: Double) = - adjustment( - NewUsageDiscount.builder() - .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) - .usageDiscount(usageDiscount) - .build() - ) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** - * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. - */ - fun adjustment(amountDiscount: NewAmountDiscount) = - adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewAmountDiscount.builder() - * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - * .amountDiscount(amountDiscount) - * .build() - * ``` - */ - fun amountDiscountAdjustment(amountDiscount: String) = - adjustment( - NewAmountDiscount.builder() - .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) - .amountDiscount(amountDiscount) - .build() - ) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ - fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ - fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Alias for calling [adjustment] with the following: - * ```java - * NewMaximum.builder() - * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - * .maximumAmount(maximumAmount) - * .build() - * ``` - */ - fun maximumAdjustment(maximumAmount: String) = - adjustment( - NewMaximum.builder() - .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) - .maximumAmount(maximumAmount) - .build() - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { - this.replacesAdjustmentId = replacesAdjustmentId - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns an immutable instance of [MeteredAllowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .meteredAllowanceConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MeteredAllowance = + MeteredAllowance( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var validated: Boolean = false - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { + if (validated) { + return@apply + } - /** - * Returns an immutable instance of [ReplaceAdjustment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .adjustment() - * .replacesAdjustmentId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toMutableMap(), - ) - } + cadence().validate() + itemId() + meteredAllowanceConfig().validate() + _modelType().let { + if (it != JsonValue.from("metered_allowance")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - adjustment().validate() - replacesAdjustmentId() - validated = true - } + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (adjustment.asKnown().getOrNull()?.validity() ?: 0) + - (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + companion object { - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val percentageDiscount: NewPercentageDiscount? = null, - private val usageDiscount: NewUsageDiscount? = null, - private val amountDiscount: NewAmountDiscount? = null, - private val minimum: NewMinimum? = null, - private val maximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { + @JvmField val ANNUAL = of("annual") - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount) + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + @JvmField val MONTHLY = of("monthly") - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + @JvmField val QUARTERLY = of("quarterly") - fun minimum(): Optional = Optional.ofNullable(minimum) + @JvmField val ONE_TIME = of("one_time") - fun maximum(): Optional = Optional.ofNullable(maximum) + @JvmField val CUSTOM = of("custom") - fun isPercentageDiscount(): Boolean = percentageDiscount != null + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun isUsageDiscount(): Boolean = usageDiscount != null + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun isAmountDiscount(): Boolean = amountDiscount != null + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun isMinimum(): Boolean = minimum != null + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun isMaximum(): Boolean = maximum != null + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun asPercentageDiscount(): NewPercentageDiscount = - percentageDiscount.getOrThrow("percentageDiscount") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + private var validated: Boolean = false - fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + known() + validated = true + } - fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun accept(visitor: Visitor): T = - when { - percentageDiscount != null -> - visitor.visitPercentageDiscount(percentageDiscount) - usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) - amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) - minimum != null -> visitor.visitMinimum(minimum) - maximum != null -> visitor.visitMaximum(maximum) - else -> visitor.unknown(_json) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - private var validated: Boolean = false + return other is Cadence && value == other.value + } - fun validate(): Adjustment = apply { - if (validated) { - return@apply + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) { - percentageDiscount.validate() - } + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { - usageDiscount.validate() - } + @JsonCreator + private constructor( + @JsonProperty("allowance_grouping_value") + @ExcludeMissing + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") + @ExcludeMissing + consumptionGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), + ) : this( + allowanceGroupingValue, + consumptionGroupingValue, + groupingKey, + unitAmount, + allowanceDisplayName, + consumptionDisplayName, + mutableMapOf(), + ) - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { - amountDiscount.validate() - } + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") - override fun visitMinimum(minimum: NewMinimum) { - minimum.validate() - } + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") - override fun visitMaximum(maximum: NewMaximum) { - maximum.validate() - } - } - ) - validated = true - } + /** + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Per-unit price applied to gross consumption and to the allowance credit. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitPercentageDiscount( - percentageDiscount: NewPercentageDiscount - ) = percentageDiscount.validity() + /** + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") - override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = - usageDiscount.validity() + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") - override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = - amountDiscount.validity() + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_grouping_value") + @ExcludeMissing + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue - override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + /** + * Returns the raw JSON value of [consumptionGroupingValue]. + * + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumption_grouping_value") + @ExcludeMissing + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue - override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName - return other is Adjustment && - percentageDiscount == other.percentageDiscount && - usageDiscount == other.usageDiscount && - amountDiscount == other.amountDiscount && - minimum == other.minimum && - maximum == other.maximum - } + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName - override fun hashCode(): Int = - Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun toString(): String = - when { - percentageDiscount != null -> - "Adjustment{percentageDiscount=$percentageDiscount}" - usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" - amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" - minimum != null -> "Adjustment{minimum=$minimum}" - maximum != null -> "Adjustment{maximum=$maximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - companion object { + fun toBuilder() = Builder().from(this) - @JvmStatic - fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = - Adjustment(percentageDiscount = percentageDiscount) + companion object { - @JvmStatic - fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = - Adjustment(usageDiscount = usageDiscount) + /** + * Returns a mutable builder for constructing an instance of + * [MeteredAllowanceConfig]. + * + * The following fields are required: + * ```java + * .allowanceGroupingValue() + * .consumptionGroupingValue() + * .groupingKey() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic - fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = - Adjustment(amountDiscount = amountDiscount) + /** A builder for [MeteredAllowanceConfig]. */ + class Builder internal constructor() { - @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() - @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) - } + @JvmSynthetic + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName + additionalProperties = + meteredAllowanceConfig.additionalProperties.toMutableMap() + } - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) - fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + /** + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) - fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + /** + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - fun visitMinimum(minimum: NewMinimum): T + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) - fun visitMaximum(maximum: NewMaximum): T + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - internal class Deserializer : BaseDeserializer(Adjustment::class) { + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) - when (adjustmentType) { - "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(percentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) - } - "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(usageDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(amountDiscount = it, _json = json) - } ?: Adjustment(_json = json) - } - "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(minimum = it, _json = json) - } ?: Adjustment(_json = json) - } - "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(maximum = it, _json = json) - } ?: Adjustment(_json = json) + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName } - } - - return Adjustment(_json = json) - } - } - internal class Serializer : BaseSerializer(Adjustment::class) { + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.percentageDiscount != null -> - generator.writeObject(value.percentageDiscount) - value.usageDiscount != null -> generator.writeObject(value.usageDiscount) - value.amountDiscount != null -> generator.writeObject(value.amountDiscount) - value.minimum != null -> generator.writeObject(value.minimum) - value.maximum != null -> generator.writeObject(value.maximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - } + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - return other is ReplaceAdjustment && - adjustment == other.adjustment && - replacesAdjustmentId == other.replacesAdjustmentId && - additionalProperties == other.additionalProperties - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private val hashCode: Int by lazy { - Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun hashCode(): Int = hashCode + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - class ReplacePrice - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val replacesPriceId: JsonField, - private val allocationPrice: JsonField, - private val discounts: JsonField>, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val maximumAmount: JsonField, - private val minimumAmount: JsonField, - private val price: JsonField, - private val priceId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), - ) : this( - replacesPriceId, - allocationPrice, - discounts, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - mutableMapOf(), - ) + /** + * Returns an immutable instance of [MeteredAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowanceGroupingValue() + * .consumptionGroupingValue() + * .groupingKey() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, + additionalProperties.toMutableMap(), + ) + } - /** - * The id of the price on the plan to replace in the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + private var validated: Boolean = false - /** - * The definition of a new allocation price to create and add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun allocationPrice(): Optional = - allocationPrice.getOptional("allocation_price") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { + if (validated) { + return@apply + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun discounts(): Optional> = discounts.getOptional("discounts") + allowanceGroupingValue() + consumptionGroupingValue() + groupingKey() + unitAmount() + allowanceDisplayName() + consumptionDisplayName() + validated = true + } - /** - * The external price id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * The new quantity of the price, if the price is a fixed price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && + additionalProperties == other.additionalProperties + } - /** - * New subscription price request body params. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") + private val hashCode: Int by lazy { + Objects.hash( + allowanceGroupingValue, + consumptionGroupingValue, + groupingKey, + unitAmount, + allowanceDisplayName, + consumptionDisplayName, + additionalProperties, + ) + } - /** - * The id of the price to add to the subscription. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun priceId(): Optional = priceId.getOptional("price_id") + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [replacesPriceId]. - * - * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId + override fun toString() = + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [allocationPrice]. - * - * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Returns the raw JSON value of [discounts]. - * - * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + companion object { - /** - * Returns the raw JSON value of [maximumAmount]. - * - * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [minimumAmount]. - * - * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [priceId]. - * - * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun toBuilder() = Builder().from(this) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - companion object { + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns a mutable builder for constructing an instance of [ReplacePrice]. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var validated: Boolean = false - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) + validated = true + } - /** - * Sets [Builder.replacesPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.replacesPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun replacesPriceId(replacesPriceId: JsonField) = apply { - this.replacesPriceId = replacesPriceId - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: NewAllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.getOrNull()) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Sets [Builder.allocationPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.allocationPrice] with a well-typed - * [NewAllocationPrice] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } + return other is Metadata && + additionalProperties == other.additionalProperties + } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = - discounts(JsonField.ofNullable(discounts)) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** Alias for calling [Builder.discounts] with `discounts.orElse(null)`. */ - @Deprecated("deprecated") - fun discounts(discounts: Optional>) = - discounts(discounts.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.discounts] to an arbitrary JSON value. - * - * You should usually call [Builder.discounts] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * Adds a single [DiscountOverride] to [discounts]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - @Deprecated("deprecated") - fun addDiscount(discount: DiscountOverride) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).also { - checkKnown("discounts", it).add(discount) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + return other is MeteredAllowance && + cadence == other.cadence && + itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + meteredAllowanceConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - /** - * Alias for [Builder.fixedPriceQuantity]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + override fun toString() = + "MeteredAllowance{cadence=$cadence, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) + class Percent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val percentConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.getOrNull()) + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("percent_config") + @ExcludeMissing + percentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - /** - * Sets [Builder.maximumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.maximumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.getOrNull()) + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Sets [Builder.minimumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.minimumAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - /** New subscription price request body params. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + /** + * Configuration for percent pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentConfig(): PercentConfig = percentConfig.getRequired("percent_config") - /** Alias for calling [Builder.price] with `price.orElse(null)`. */ - fun price(price: Optional) = price(price.getOrNull()) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Price] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun price(price: JsonField) = apply { this.price = price } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ - fun price(bulkWithFilters: Price.BulkWithFilters) = - price(Price.ofBulkWithFilters(bulkWithFilters)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - /** Alias for calling [price] with `Price.ofPackage(package_)`. */ - fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ - fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. - */ - fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - /** - * Alias for calling [price] with - * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. - */ - fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - /** - * Alias for calling [price] with - * `Price.ofPackageWithAllocation(packageWithAllocation)`. - */ - fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. - */ - fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - /** - * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. - */ - fun price(tieredWithProration: Price.TieredWithProration) = - price(Price.ofTieredWithProration(tieredWithProration)) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + /** + * Returns the raw JSON value of [percentConfig]. + * + * Unlike [percentConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent_config") + @ExcludeMissing + fun _percentConfig(): JsonField = percentConfig - /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Alias for calling [price] with - * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. - */ - fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. - */ - fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** - * Alias for calling [price] with - * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. - */ - fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = - price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Alias for calling [price] with - * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. - */ - fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. - */ - fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Alias for calling [price] with - * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. - */ - fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. - */ - fun price( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Alias for calling [price] with - * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. - */ - fun price( - scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. - */ - fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Alias for calling [price] with - * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. - */ - fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = - price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ - fun price(minimumComposite: NewSubscriptionMinimumCompositePrice) = - price(Price.ofMinimumComposite(minimumComposite)) + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - /** Alias for calling [price] with `Price.ofPercent(percent)`. */ - fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ - fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ - fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.priceId] to an arbitrary JSON value. - * - * You should usually call [Builder.priceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun toBuilder() = Builder().from(this) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns a mutable builder for constructing an instance of [Percent]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** A builder for [Percent]. */ + class Builder internal constructor() { - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("percent") + private var name: JsonField? = null + private var percentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmSynthetic + internal fun from(percent: Percent) = apply { + cadence = percent.cadence + itemId = percent.itemId + modelType = percent.modelType + name = percent.name + percentConfig = percent.percentConfig + billableMetricId = percent.billableMetricId + billedInAdvance = percent.billedInAdvance + billingCycleConfiguration = percent.billingCycleConfiguration + conversionRate = percent.conversionRate + conversionRateConfig = percent.conversionRateConfig + currency = percent.currency + dimensionalPriceConfiguration = percent.dimensionalPriceConfiguration + externalPriceId = percent.externalPriceId + fixedPriceQuantity = percent.fixedPriceQuantity + invoiceGroupingKey = percent.invoiceGroupingKey + invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId + metadata = percent.metadata + referenceId = percent.referenceId + additionalProperties = percent.additionalProperties.toMutableMap() + } - /** - * Returns an immutable instance of [ReplacePrice]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .replacesPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toMutableMap(), - ) - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - private var validated: Boolean = false + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - discounts().ifPresent { it.forEach { it.validate() } } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price().ifPresent { it.validate() } - priceId() - validated = true - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (replacesPriceId.asKnown().isPresent) 1 else 0) + - (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + - (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (maximumAmount.asKnown().isPresent) 1 else 0) + - (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (price.asKnown().getOrNull()?.validity() ?: 0) + - (if (priceId.asKnown().isPresent) 1 else 0) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** New subscription price request body params. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val unit: NewSubscriptionUnitPrice? = null, - private val tiered: NewSubscriptionTieredPrice? = null, - private val bulk: NewSubscriptionBulkPrice? = null, - private val bulkWithFilters: BulkWithFilters? = null, - private val package_: NewSubscriptionPackagePrice? = null, - private val matrix: NewSubscriptionMatrixPrice? = null, - private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, - private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, - private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, - private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = - null, - private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, - private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProration? = null, - private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, - private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, - private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, - private val groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, - private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, - private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, - private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, - private val minimumComposite: NewSubscriptionMinimumCompositePrice? = null, - private val percent: Percent? = null, - private val eventOutput: EventOutput? = null, - private val _json: JsonValue? = null, - ) { + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun unit(): Optional = Optional.ofNullable(unit) + /** Configuration for percent pricing */ + fun percentConfig(percentConfig: PercentConfig) = + percentConfig(JsonField.of(percentConfig)) - fun tiered(): Optional = Optional.ofNullable(tiered) + /** + * Sets [Builder.percentConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.percentConfig] with a well-typed + * [PercentConfig] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun percentConfig(percentConfig: JsonField) = apply { + this.percentConfig = percentConfig + } - fun bulk(): Optional = Optional.ofNullable(bulk) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - fun package_(): Optional = Optional.ofNullable(package_) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun matrix(): Optional = Optional.ofNullable(matrix) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun thresholdTotalAmount(): Optional = - Optional.ofNullable(thresholdTotalAmount) + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun tieredPackage(): Optional = - Optional.ofNullable(tieredPackage) + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun groupedTiered(): Optional = - Optional.ofNullable(groupedTiered) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun tieredPackageWithMinimum(): Optional = - Optional.ofNullable(tieredPackageWithMinimum) + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - fun packageWithAllocation(): Optional = - Optional.ofNullable(packageWithAllocation) + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun unitWithPercent(): Optional = - Optional.ofNullable(unitWithPercent) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun matrixWithAllocation(): Optional = - Optional.ofNullable(matrixWithAllocation) + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun tieredWithProration(): Optional = - Optional.ofNullable(tieredWithProration) + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) - - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) - - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) - - fun groupedWithProratedMinimum(): - Optional = - Optional.ofNullable(groupedWithProratedMinimum) - - fun groupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(groupedWithMeteredMinimum) - - fun groupedWithMinMaxThresholds(): Optional = - Optional.ofNullable(groupedWithMinMaxThresholds) - - fun matrixWithDisplayName(): Optional = - Optional.ofNullable(matrixWithDisplayName) + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun groupedTieredPackage(): Optional = - Optional.ofNullable(groupedTieredPackage) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun maxGroupTieredPackage(): Optional = - Optional.ofNullable(maxGroupTieredPackage) + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun scalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithUnitPricing) + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun scalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(scalableMatrixWithTieredPricing) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun cumulativeGroupedBulk(): Optional = - Optional.ofNullable(cumulativeGroupedBulk) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun cumulativeGroupedAllocation(): Optional = - Optional.ofNullable(cumulativeGroupedAllocation) + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun minimumComposite(): Optional = - Optional.ofNullable(minimumComposite) + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun percent(): Optional = Optional.ofNullable(percent) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun isUnit(): Boolean = unit != null + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun isTiered(): Boolean = tiered != null + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun isBulk(): Boolean = bulk != null + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - fun isBulkWithFilters(): Boolean = bulkWithFilters != null + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun isPackage(): Boolean = package_ != null + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun isMatrix(): Boolean = matrix != null + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - fun isTieredPackage(): Boolean = tieredPackage != null + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun isGroupedTiered(): Boolean = groupedTiered != null + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - fun isUnitWithPercent(): Boolean = unitWithPercent != null + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - fun isTieredWithProration(): Boolean = tieredWithProration != null + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - fun isUnitWithProration(): Boolean = unitWithProration != null + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun isGroupedAllocation(): Boolean = groupedAllocation != null + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun isBulkWithProration(): Boolean = bulkWithProration != null + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun isScalableMatrixWithTieredPricing(): Boolean = - scalableMatrixWithTieredPricing != null + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun isMinimumComposite(): Boolean = minimumComposite != null + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun isPercent(): Boolean = percent != null + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun isEventOutput(): Boolean = eventOutput != null + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + /** + * Returns an immutable instance of [Percent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .percentConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Percent = + Percent( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("percentConfig", percentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } - fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + private var validated: Boolean = false - fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Percent = apply { + if (validated) { + return@apply + } - fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + percentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("percent")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (percentConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) - fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { - fun asTieredPackage(): NewSubscriptionTieredPackagePrice = - tieredPackage.getOrThrow("tieredPackage") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the 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 asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + companion object { - fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = - groupedTiered.getOrThrow("groupedTiered") + @JvmField val ANNUAL = of("annual") - fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = - tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = - packageWithAllocation.getOrThrow("packageWithAllocation") + @JvmField val MONTHLY = of("monthly") - fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - unitWithPercent.getOrThrow("unitWithPercent") + @JvmField val QUARTERLY = of("quarterly") - fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = - matrixWithAllocation.getOrThrow("matrixWithAllocation") + @JvmField val ONE_TIME = of("one_time") - fun asTieredWithProration(): TieredWithProration = - tieredWithProration.getOrThrow("tieredWithProration") + @JvmField val CUSTOM = of("custom") - fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = - groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = - groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = - groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = - matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + private var validated: Boolean = false - fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - groupedTieredPackage.getOrThrow("groupedTieredPackage") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = - maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + known() + validated = true + } - fun asScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - fun asScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = - cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = - cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + return other is Cadence && value == other.value + } - fun asMinimumComposite(): NewSubscriptionMinimumCompositePrice = - minimumComposite.getOrThrow("minimumComposite") + override fun hashCode() = value.hashCode() - fun asPercent(): Percent = percent.getOrThrow("percent") + override fun toString() = value.toString() + } - fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + /** Configuration for percent pricing */ + class PercentConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val percent: JsonField, + private val additionalProperties: MutableMap, + ) { - fun _json(): Optional = Optional.ofNullable(_json) + @JsonCreator + private constructor( + @JsonProperty("percent") + @ExcludeMissing + percent: JsonField = JsonMissing.of() + ) : this(percent, mutableMapOf()) - fun accept(visitor: Visitor): T = - when { - unit != null -> visitor.visitUnit(unit) - tiered != null -> visitor.visitTiered(tiered) - bulk != null -> visitor.visitBulk(bulk) - bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) - package_ != null -> visitor.visitPackage(package_) - matrix != null -> visitor.visitMatrix(matrix) - thresholdTotalAmount != null -> - visitor.visitThresholdTotalAmount(thresholdTotalAmount) - tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) - tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) - groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) - tieredPackageWithMinimum != null -> - visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) - packageWithAllocation != null -> - visitor.visitPackageWithAllocation(packageWithAllocation) - unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) - matrixWithAllocation != null -> - visitor.visitMatrixWithAllocation(matrixWithAllocation) - tieredWithProration != null -> - visitor.visitTieredWithProration(tieredWithProration) - unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) - groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) - bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) - groupedWithProratedMinimum != null -> - visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) - groupedWithMeteredMinimum != null -> - visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) - groupedWithMinMaxThresholds != null -> - visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) - matrixWithDisplayName != null -> - visitor.visitMatrixWithDisplayName(matrixWithDisplayName) - groupedTieredPackage != null -> - visitor.visitGroupedTieredPackage(groupedTieredPackage) - maxGroupTieredPackage != null -> - visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) - scalableMatrixWithUnitPricing != null -> - visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) - scalableMatrixWithTieredPricing != null -> - visitor.visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing - ) - cumulativeGroupedBulk != null -> - visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) - cumulativeGroupedAllocation != null -> - visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) - minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) - percent != null -> visitor.visitPercent(percent) - eventOutput != null -> visitor.visitEventOutput(eventOutput) - else -> visitor.unknown(_json) - } + /** + * What percent of the component subtotals to charge + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun percent(): Double = percent.getRequired("percent") - private var validated: Boolean = false + /** + * Returns the raw JSON value of [percent]. + * + * Unlike [percent], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percent") + @ExcludeMissing + fun _percent(): JsonField = percent - fun validate(): Price = apply { - if (validated) { - return@apply - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) { - unit.validate() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun visitTiered(tiered: NewSubscriptionTieredPrice) { - tiered.validate() - } + fun toBuilder() = Builder().from(this) - override fun visitBulk(bulk: NewSubscriptionBulkPrice) { - bulk.validate() - } + companion object { - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { - bulkWithFilters.validate() - } + /** + * Returns a mutable builder for constructing an instance of + * [PercentConfig]. + * + * The following fields are required: + * ```java + * .percent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) { - package_.validate() - } + /** A builder for [PercentConfig]. */ + class Builder internal constructor() { - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { - matrix.validate() - } + private var percent: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) { - thresholdTotalAmount.validate() + @JvmSynthetic + internal fun from(percentConfig: PercentConfig) = apply { + percent = percentConfig.percent + additionalProperties = percentConfig.additionalProperties.toMutableMap() } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) { - tieredPackage.validate() - } + /** What percent of the component subtotals to charge */ + fun percent(percent: Double) = percent(JsonField.of(percent)) - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - tieredWithMinimum.validate() - } + /** + * Sets [Builder.percent] to an arbitrary JSON value. + * + * You should usually call [Builder.percent] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percent(percent: JsonField) = apply { this.percent = percent } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) { - groupedTiered.validate() - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) { - tieredPackageWithMinimum.validate() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) { - packageWithAllocation.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - unitWithPercent.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) { - matrixWithAllocation.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) { - tieredWithProration.validate() - } + /** + * Returns an immutable instance of [PercentConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .percent() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PercentConfig = + PercentConfig( + checkRequired("percent", percent), + additionalProperties.toMutableMap(), + ) + } - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - unitWithProration.validate() - } + private var validated: Boolean = false - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - groupedAllocation.validate() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): PercentConfig = apply { + if (validated) { + return@apply } - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - bulkWithProration.validate() - } + percent() + validated = true + } - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - groupedWithProratedMinimum.validate() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) { - groupedWithMeteredMinimum.validate() - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (percent.asKnown().isPresent) 1 else 0) - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) { - groupedWithMinMaxThresholds.validate() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) { - matrixWithDisplayName.validate() - } + return other is PercentConfig && + percent == other.percent && + additionalProperties == other.additionalProperties + } - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) { - groupedTieredPackage.validate() - } + private val hashCode: Int by lazy { + Objects.hash(percent, additionalProperties) + } - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) { - maxGroupTieredPackage.validate() - } + override fun hashCode(): Int = hashCode - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) { - scalableMatrixWithUnitPricing.validate() - } + override fun toString() = + "PercentConfig{percent=$percent, additionalProperties=$additionalProperties}" + } - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) { - scalableMatrixWithTieredPricing.validate() - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) { - cumulativeGroupedBulk.validate() + @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() } - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) { - cumulativeGroupedAllocation.validate() + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitMinimumComposite( - minimumComposite: NewSubscriptionMinimumCompositePrice - ) { - minimumComposite.validate() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitPercent(percent: Percent) { - percent.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - override fun visitEventOutput(eventOutput: EventOutput) { - eventOutput.validate() - } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - override fun visitTiered(tiered: NewSubscriptionTieredPrice) = - tiered.validity() + validated = true + } - override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = - bulkWithFilters.validity() + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } - override fun visitPackage(package_: NewSubscriptionPackagePrice) = - package_.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = - matrix.validity() + return other is Metadata && + additionalProperties == other.additionalProperties + } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun visitTieredPackage( - tieredPackage: NewSubscriptionTieredPackagePrice - ) = tieredPackage.validity() + override fun hashCode(): Int = hashCode - override fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = tieredWithMinimum.validity() + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - override fun visitGroupedTiered( - groupedTiered: NewSubscriptionGroupedTieredPrice - ) = groupedTiered.validity() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = tieredPackageWithMinimum.validity() + return other is Percent && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + percentConfig == other.percentConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - override fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = packageWithAllocation.validity() + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + percentConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - override fun visitUnitWithPercent( - unitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = unitWithPercent.validity() + override fun hashCode(): Int = hashCode - override fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + override fun toString() = + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProration - ) = tieredWithProration.validity() + class EventOutput + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val eventOutputConfig: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ) = unitWithProration.validity() + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("event_output_config") + @ExcludeMissing + eventOutputConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - override fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = groupedAllocation.validity() + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - override fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = bulkWithProration.validity() + /** + * Configuration for event_output pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun eventOutputConfig(): EventOutputConfig = + eventOutputConfig.getRequired("event_output_config") - override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = groupedWithProratedMinimum.validity() + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = groupedWithMeteredMinimum.validity() + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - override fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = groupedWithMinMaxThresholds.validity() + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - override fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = matrixWithDisplayName.validity() + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - override fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = maxGroupTieredPackage.validity() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = scalableMatrixWithUnitPricing.validity() + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") - override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = scalableMatrixWithTieredPricing.validity() + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = cumulativeGroupedBulk.validity() + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - override fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = cumulativeGroupedAllocation.validity() + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - override fun visitMinimumComposite( - minimumComposite: NewSubscriptionMinimumCompositePrice - ) = minimumComposite.validity() + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - override fun visitPercent(percent: Percent) = percent.validity() + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - override fun visitEventOutput(eventOutput: EventOutput) = - eventOutput.validity() + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - return other is Price && - unit == other.unit && - tiered == other.tiered && - bulk == other.bulk && - bulkWithFilters == other.bulkWithFilters && - package_ == other.package_ && - matrix == other.matrix && - thresholdTotalAmount == other.thresholdTotalAmount && - tieredPackage == other.tieredPackage && - tieredWithMinimum == other.tieredWithMinimum && - groupedTiered == other.groupedTiered && - tieredPackageWithMinimum == other.tieredPackageWithMinimum && - packageWithAllocation == other.packageWithAllocation && - unitWithPercent == other.unitWithPercent && - matrixWithAllocation == other.matrixWithAllocation && - tieredWithProration == other.tieredWithProration && - unitWithProration == other.unitWithProration && - groupedAllocation == other.groupedAllocation && - bulkWithProration == other.bulkWithProration && - groupedWithProratedMinimum == other.groupedWithProratedMinimum && - groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && - groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && - matrixWithDisplayName == other.matrixWithDisplayName && - groupedTieredPackage == other.groupedTieredPackage && - maxGroupTieredPackage == other.maxGroupTieredPackage && - scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && - scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && - cumulativeGroupedBulk == other.cumulativeGroupedBulk && - cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && - minimumComposite == other.minimumComposite && - percent == other.percent && - eventOutput == other.eventOutput - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - override fun hashCode(): Int = - Objects.hash( - unit, - tiered, - bulk, - bulkWithFilters, - package_, - matrix, - thresholdTotalAmount, - tieredPackage, - tieredWithMinimum, - groupedTiered, - tieredPackageWithMinimum, - packageWithAllocation, - unitWithPercent, - matrixWithAllocation, - tieredWithProration, - unitWithProration, - groupedAllocation, - bulkWithProration, - groupedWithProratedMinimum, - groupedWithMeteredMinimum, - groupedWithMinMaxThresholds, - matrixWithDisplayName, - groupedTieredPackage, - maxGroupTieredPackage, - scalableMatrixWithUnitPricing, - scalableMatrixWithTieredPricing, - cumulativeGroupedBulk, - cumulativeGroupedAllocation, - minimumComposite, - percent, - eventOutput, - ) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - override fun toString(): String = - when { - unit != null -> "Price{unit=$unit}" - tiered != null -> "Price{tiered=$tiered}" - bulk != null -> "Price{bulk=$bulk}" - bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" - package_ != null -> "Price{package_=$package_}" - matrix != null -> "Price{matrix=$matrix}" - thresholdTotalAmount != null -> - "Price{thresholdTotalAmount=$thresholdTotalAmount}" - tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" - tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" - groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" - tieredPackageWithMinimum != null -> - "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" - packageWithAllocation != null -> - "Price{packageWithAllocation=$packageWithAllocation}" - unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" - matrixWithAllocation != null -> - "Price{matrixWithAllocation=$matrixWithAllocation}" - tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" - unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" - groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" - bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" - groupedWithProratedMinimum != null -> - "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" - groupedWithMeteredMinimum != null -> - "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" - groupedWithMinMaxThresholds != null -> - "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" - matrixWithDisplayName != null -> - "Price{matrixWithDisplayName=$matrixWithDisplayName}" - groupedTieredPackage != null -> - "Price{groupedTieredPackage=$groupedTieredPackage}" - maxGroupTieredPackage != null -> - "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" - scalableMatrixWithUnitPricing != null -> - "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" - scalableMatrixWithTieredPricing != null -> - "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" - cumulativeGroupedBulk != null -> - "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" - cumulativeGroupedAllocation != null -> - "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" - minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" - percent != null -> "Price{percent=$percent}" - eventOutput != null -> "Price{eventOutput=$eventOutput}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - companion object { + /** + * Returns the raw JSON value of [eventOutputConfig]. + * + * Unlike [eventOutputConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_output_config") + @ExcludeMissing + fun _eventOutputConfig(): JsonField = eventOutputConfig - @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmStatic - fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = - Price(bulkWithFilters = bulkWithFilters) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JvmStatic - fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JvmStatic - fun ofThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(thresholdTotalAmount = thresholdTotalAmount) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - @JvmStatic - fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = - Price(tieredPackage = tieredPackage) + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = - Price(tieredWithMinimum = tieredWithMinimum) + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - @JvmStatic - fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - @JvmStatic - fun ofTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JvmStatic - fun ofPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = Price(packageWithAllocation = packageWithAllocation) + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - @JvmStatic - fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = - Price(unitWithPercent = unitWithPercent) + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JvmStatic - fun ofMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ) = Price(matrixWithAllocation = matrixWithAllocation) + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - @JvmStatic - fun ofTieredWithProration(tieredWithProration: TieredWithProration) = - Price(tieredWithProration = tieredWithProration) + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - @JvmStatic - fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = - Price(unitWithProration = unitWithProration) + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - @JvmStatic - fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = - Price(groupedAllocation = groupedAllocation) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmStatic - fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = - Price(bulkWithProration = bulkWithProration) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + fun toBuilder() = Builder().from(this) - @JvmStatic - fun ofGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + companion object { - @JvmStatic - fun ofGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + /** + * Returns a mutable builder for constructing an instance of [EventOutput]. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic - fun ofMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = Price(matrixWithDisplayName = matrixWithDisplayName) + /** A builder for [EventOutput]. */ + class Builder internal constructor() { - @JvmStatic - fun ofGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(groupedTieredPackage = groupedTieredPackage) + private var cadence: JsonField? = null + private var eventOutputConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("event_output") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JvmStatic - fun ofMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + @JvmSynthetic + internal fun from(eventOutput: EventOutput) = apply { + cadence = eventOutput.cadence + eventOutputConfig = eventOutput.eventOutputConfig + itemId = eventOutput.itemId + modelType = eventOutput.modelType + name = eventOutput.name + billableMetricId = eventOutput.billableMetricId + billedInAdvance = eventOutput.billedInAdvance + billingCycleConfiguration = eventOutput.billingCycleConfiguration + conversionRate = eventOutput.conversionRate + conversionRateConfig = eventOutput.conversionRateConfig + currency = eventOutput.currency + dimensionalPriceConfiguration = eventOutput.dimensionalPriceConfiguration + externalPriceId = eventOutput.externalPriceId + fixedPriceQuantity = eventOutput.fixedPriceQuantity + invoiceGroupingKey = eventOutput.invoiceGroupingKey + invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId + metadata = eventOutput.metadata + referenceId = eventOutput.referenceId + additionalProperties = eventOutput.additionalProperties.toMutableMap() + } - @JvmStatic - fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JvmStatic - fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - @JvmStatic - fun ofCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + /** Configuration for event_output pricing */ + fun eventOutputConfig(eventOutputConfig: EventOutputConfig) = + eventOutputConfig(JsonField.of(eventOutputConfig)) - @JvmStatic - fun ofCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + /** + * Sets [Builder.eventOutputConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.eventOutputConfig] with a well-typed + * [EventOutputConfig] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun eventOutputConfig(eventOutputConfig: JsonField) = apply { + this.eventOutputConfig = eventOutputConfig + } - @JvmStatic - fun ofMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice) = - Price(minimumComposite = minimumComposite) + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - @JvmStatic - fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("event_output") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - fun visitUnit(unit: NewSubscriptionUnitPrice): T + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - fun visitTiered(tiered: NewSubscriptionTieredPrice): T + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun visitBulk(bulk: NewSubscriptionBulkPrice): T + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - fun visitPackage(package_: NewSubscriptionPackagePrice): T + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun visitThresholdTotalAmount( - thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun visitTieredWithMinimum( - tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice - ): T + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun visitPackageWithAllocation( - packageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - fun visitMatrixWithAllocation( - matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice - ): T + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun visitUnitWithProration( - unitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - fun visitGroupedAllocation( - groupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - fun visitBulkWithProration( - bulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice - ): T + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice - ): T + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - fun visitGroupedWithMinMaxThresholds( - groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds - ): T + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - fun visitMatrixWithDisplayName( - matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - fun visitGroupedTieredPackage( - groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice - ): T + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ): T + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - fun visitCumulativeGroupedAllocation( - cumulativeGroupedAllocation: CumulativeGroupedAllocation - ): T + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun visitMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice): T + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun visitPercent(percent: Percent): T + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - fun visitEventOutput(eventOutput: EventOutput): T + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EventOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .eventOutputConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutput = + EventOutput( + checkRequired("cadence", cadence), + checkRequired("eventOutputConfig", eventOutputConfig), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false /** - * Maps an unknown variant of [Price] to a value of type [T]. + * Validates that the types of all values in this object match their expected types + * recursively. * - * An instance of [Price] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * This method is _not_ forwards compatible with new types from the API for existing + * fields. * - * @throws OrbInvalidDataException in the default implementation. + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Price: $json") - } - } + fun validate(): EventOutput = apply { + if (validated) { + return@apply + } - internal class Deserializer : BaseDeserializer(Price::class) { + cadence().validate() + eventOutputConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("event_output")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - override fun ObjectCodec.deserialize(node: JsonNode): Price { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - when (modelType) { - "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) - } - "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (eventOutputConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("event_output")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } - "bulk_with_filters" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(bulkWithFilters = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply } - "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(thresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for event_output pricing */ + class EventOutputConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitRatingKey: JsonField, + private val defaultUnitRate: JsonField, + private val groupingKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_rating_key") + @ExcludeMissing + unitRatingKey: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_rate") + @ExcludeMissing + defaultUnitRate: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + ) : this(unitRatingKey, defaultUnitRate, groupingKey, mutableMapOf()) + + /** + * The key in the event data to extract the unit rate from. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitRatingKey(): String = unitRatingKey.getRequired("unit_rating_key") + + /** + * If provided, this amount will be used as the unit rate when an event does not + * have a value for the `unit_rating_key`. If not provided, events missing a + * unit rate will be ignored. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun defaultUnitRate(): Optional = + defaultUnitRate.getOptional("default_unit_rate") + + /** + * An optional key in the event data to group by (e.g., event ID). All events + * will also be grouped by their unit rate. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun groupingKey(): Optional = groupingKey.getOptional("grouping_key") + + /** + * Returns the raw JSON value of [unitRatingKey]. + * + * Unlike [unitRatingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_rating_key") + @ExcludeMissing + fun _unitRatingKey(): JsonField = unitRatingKey + + /** + * Returns the raw JSON value of [defaultUnitRate]. + * + * Unlike [defaultUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_unit_rate") + @ExcludeMissing + fun _defaultUnitRate(): JsonField = defaultUnitRate + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EventOutputConfig]. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EventOutputConfig]. */ + class Builder internal constructor() { + + private var unitRatingKey: JsonField? = null + private var defaultUnitRate: JsonField = JsonMissing.of() + private var groupingKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(eventOutputConfig: EventOutputConfig) = apply { + unitRatingKey = eventOutputConfig.unitRatingKey + defaultUnitRate = eventOutputConfig.defaultUnitRate + groupingKey = eventOutputConfig.groupingKey + additionalProperties = + eventOutputConfig.additionalProperties.toMutableMap() } - "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + + /** The key in the event data to extract the unit rate from. */ + fun unitRatingKey(unitRatingKey: String) = + unitRatingKey(JsonField.of(unitRatingKey)) + + /** + * Sets [Builder.unitRatingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.unitRatingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun unitRatingKey(unitRatingKey: JsonField) = apply { + this.unitRatingKey = unitRatingKey } - "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTiered = it, _json = json) } - ?: Price(_json = json) + + /** + * If provided, this amount will be used as the unit rate when an event does + * not have a value for the `unit_rating_key`. If not provided, events + * missing a unit rate will be ignored. + */ + fun defaultUnitRate(defaultUnitRate: String?) = + defaultUnitRate(JsonField.ofNullable(defaultUnitRate)) + + /** + * Alias for calling [Builder.defaultUnitRate] with + * `defaultUnitRate.orElse(null)`. + */ + fun defaultUnitRate(defaultUnitRate: Optional) = + defaultUnitRate(defaultUnitRate.getOrNull()) + + /** + * Sets [Builder.defaultUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitRate] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitRate(defaultUnitRate: JsonField) = apply { + this.defaultUnitRate = defaultUnitRate } - "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + + /** + * An optional key in the event data to group by (e.g., event ID). All + * events will also be grouped by their unit rate. + */ + fun groupingKey(groupingKey: String?) = + groupingKey(JsonField.ofNullable(groupingKey)) + + /** + * Alias for calling [Builder.groupingKey] with `groupingKey.orElse(null)`. + */ + fun groupingKey(groupingKey: Optional) = + groupingKey(groupingKey.getOrNull()) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } - "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(packageWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithPercent = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithAllocation = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredWithProration = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [EventOutputConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .unitRatingKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EventOutputConfig = + EventOutputConfig( + checkRequired("unitRatingKey", unitRatingKey), + defaultUnitRate, + groupingKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): EventOutputConfig = apply { + if (validated) { + return@apply } - "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(unitWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedAllocation = it, _json = json) } - ?: Price(_json = json) - } - "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(bulkWithProration = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } - ?: Price(_json = json) - } - "grouped_with_min_max_thresholds" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } - ?: Price(_json = json) - } - "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(matrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + + unitRatingKey() + defaultUnitRate() + groupingKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(groupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitRatingKey.asKnown().isPresent) 1 else 0) + + (if (defaultUnitRate.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(maxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + + return other is EventOutputConfig && + unitRatingKey == other.unitRatingKey && + defaultUnitRate == other.defaultUnitRate && + groupingKey == other.groupingKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + unitRatingKey, + defaultUnitRate, + groupingKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutputConfig{unitRatingKey=$unitRatingKey, defaultUnitRate=$defaultUnitRate, groupingKey=$groupingKey, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } - ?: Price(_json = json) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), - ) - ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } - ?: Price(_json = json) + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - "cumulative_grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply } - "minimum_composite" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(minimumComposite = it, _json = json) } - ?: Price(_json = json) + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - "percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(percent = it, _json = json) - } ?: Price(_json = json) + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - "event_output" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(eventOutput = it, _json = json) - } ?: Price(_json = json) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Metadata && + additionalProperties == other.additionalProperties } - return Price(_json = json) - } - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - internal class Serializer : BaseSerializer(Price::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unit != null -> generator.writeObject(value.unit) - value.tiered != null -> generator.writeObject(value.tiered) - value.bulk != null -> generator.writeObject(value.bulk) - value.bulkWithFilters != null -> - generator.writeObject(value.bulkWithFilters) - value.package_ != null -> generator.writeObject(value.package_) - value.matrix != null -> generator.writeObject(value.matrix) - value.thresholdTotalAmount != null -> - generator.writeObject(value.thresholdTotalAmount) - value.tieredPackage != null -> generator.writeObject(value.tieredPackage) - value.tieredWithMinimum != null -> - generator.writeObject(value.tieredWithMinimum) - value.groupedTiered != null -> generator.writeObject(value.groupedTiered) - value.tieredPackageWithMinimum != null -> - generator.writeObject(value.tieredPackageWithMinimum) - value.packageWithAllocation != null -> - generator.writeObject(value.packageWithAllocation) - value.unitWithPercent != null -> - generator.writeObject(value.unitWithPercent) - value.matrixWithAllocation != null -> - generator.writeObject(value.matrixWithAllocation) - value.tieredWithProration != null -> - generator.writeObject(value.tieredWithProration) - value.unitWithProration != null -> - generator.writeObject(value.unitWithProration) - value.groupedAllocation != null -> - generator.writeObject(value.groupedAllocation) - value.bulkWithProration != null -> - generator.writeObject(value.bulkWithProration) - value.groupedWithProratedMinimum != null -> - generator.writeObject(value.groupedWithProratedMinimum) - value.groupedWithMeteredMinimum != null -> - generator.writeObject(value.groupedWithMeteredMinimum) - value.groupedWithMinMaxThresholds != null -> - generator.writeObject(value.groupedWithMinMaxThresholds) - value.matrixWithDisplayName != null -> - generator.writeObject(value.matrixWithDisplayName) - value.groupedTieredPackage != null -> - generator.writeObject(value.groupedTieredPackage) - value.maxGroupTieredPackage != null -> - generator.writeObject(value.maxGroupTieredPackage) - value.scalableMatrixWithUnitPricing != null -> - generator.writeObject(value.scalableMatrixWithUnitPricing) - value.scalableMatrixWithTieredPricing != null -> - generator.writeObject(value.scalableMatrixWithTieredPricing) - value.cumulativeGroupedBulk != null -> - generator.writeObject(value.cumulativeGroupedBulk) - value.cumulativeGroupedAllocation != null -> - generator.writeObject(value.cumulativeGroupedAllocation) - value.minimumComposite != null -> - generator.writeObject(value.minimumComposite) - value.percent != null -> generator.writeObject(value.percent) - value.eventOutput != null -> generator.writeObject(value.eventOutput) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is EventOutput && + cadence == other.cadence && + eventOutputConfig == other.eventOutputConfig && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + eventOutputConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - class BulkWithFilters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val bulkWithFiltersConfig: JsonField, - private val cadence: JsonField, - private val itemId: JsonField, - private val modelType: JsonValue, - private val name: JsonField, - private val billableMetricId: JsonField, - private val billedInAdvance: JsonField, - private val billingCycleConfiguration: JsonField, - private val conversionRate: JsonField, - private val conversionRateConfig: JsonField, - private val currency: JsonField, - private val dimensionalPriceConfiguration: - JsonField, - private val externalPriceId: JsonField, - private val fixedPriceQuantity: JsonField, - private val invoiceGroupingKey: JsonField, - private val invoicingCycleConfiguration: JsonField, - private val metadata: JsonField, - private val referenceId: JsonField, - private val additionalProperties: MutableMap, - ) { + return other is AddPrice && + allocationPrice == other.allocationPrice && + discounts == other.discounts && + endDate == other.endDate && + externalPriceId == other.externalPriceId && + maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && + minimumAmount == other.minimumAmount && + planPhaseOrder == other.planPhaseOrder && + price == other.price && + priceId == other.priceId && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } - @JsonCreator - private constructor( - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - bulkWithFiltersConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonValue = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate_config") - @ExcludeMissing - conversionRateConfig: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - referenceId: JsonField = JsonMissing.of(), - ) : this( - bulkWithFiltersConfig, - cadence, - itemId, - modelType, - name, - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - mutableMapOf(), - ) + private val hashCode: Int by lazy { + Objects.hash( + allocationPrice, + discounts, + endDate, + externalPriceId, + maximumAmount, + metricParameterOverrides, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. + */ + class BillingCycleAlignment + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNCHANGED = of("unchanged") + + @JvmField val PLAN_CHANGE_DATE = of("plan_change_date") + + @JvmField val START_OF_MONTH = of("start_of_month") + + @JvmStatic fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) + } + + /** An enum containing [BillingCycleAlignment]'s known values. */ + enum class Known { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + } + + /** + * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, + /** + * An enum member indicating that [BillingCycleAlignment] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNCHANGED -> Value.UNCHANGED + PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE + START_OF_MONTH -> Value.START_OF_MONTH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + UNCHANGED -> Known.UNCHANGED + PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE + START_OF_MONTH -> Known.START_OF_MONTH + else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): BillingCycleAlignment = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BillingCycleAlignment && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class RemoveAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + adjustmentId: JsonField = JsonMissing.of() + ) : this(adjustmentId, mutableMapOf()) + + /** + * The id of the adjustment to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** + * Returns the raw JSON value of [adjustmentId]. + * + * Unlike [adjustmentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAdjustment]. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveAdjustment]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeAdjustment: RemoveAdjustment) = apply { + adjustmentId = removeAdjustment.adjustmentId + additionalProperties = removeAdjustment.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** + * Sets [Builder.adjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustmentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RemoveAdjustment = + RemoveAdjustment( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RemoveAdjustment = apply { + if (validated) { + return@apply + } + + adjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (adjustmentId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAdjustment && + adjustmentId == other.adjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" + } + + class RemovePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val externalPriceId: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this(externalPriceId, priceId, mutableMapOf()) + + /** + * The external price id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + + /** + * The id of the price to remove on the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): Optional = priceId.getOptional("price_id") + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemovePrice]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovePrice]. */ + class Builder internal constructor() { + + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removePrice: RemovePrice) = apply { + externalPriceId = removePrice.externalPriceId + priceId = removePrice.priceId + additionalProperties = removePrice.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemovePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemovePrice = + RemovePrice(externalPriceId, priceId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RemovePrice = apply { + if (validated) { + return@apply + } + + externalPriceId() + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemovePrice && + externalPriceId == other.externalPriceId && + priceId == other.priceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(externalPriceId, priceId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" + } + + class ReplaceAdjustment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adjustment: JsonField, + private val replacesAdjustmentId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + replacesAdjustmentId: JsonField = JsonMissing.of(), + ) : this(adjustment, replacesAdjustmentId, mutableMapOf()) + + /** + * The definition of a new adjustment to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The id of the adjustment on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** + * Returns the raw JSON value of [adjustment]. + * + * Unlike [adjustment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * Returns the raw JSON value of [replacesAdjustmentId]. + * + * Unlike [replacesAdjustmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplaceAdjustment]. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplaceAdjustment]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replaceAdjustment: ReplaceAdjustment) = apply { + adjustment = replaceAdjustment.adjustment + replacesAdjustmentId = replaceAdjustment.replacesAdjustmentId + additionalProperties = replaceAdjustment.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + + /** + * Sets [Builder.adjustment] to an arbitrary JSON value. + * + * You should usually call [Builder.adjustment] with a well-typed [Adjustment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** + * Alias for calling [adjustment] with + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. + */ + fun adjustment(percentageDiscount: NewPercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewPercentageDiscount.builder() + * .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + * .percentageDiscount(percentageDiscount) + * .build() + * ``` + */ + fun percentageDiscountAdjustment(percentageDiscount: Double) = + adjustment( + NewPercentageDiscount.builder() + .adjustmentType(NewPercentageDiscount.AdjustmentType.PERCENTAGE_DISCOUNT) + .percentageDiscount(percentageDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: NewUsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewUsageDiscount.builder() + * .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + * .usageDiscount(usageDiscount) + * .build() + * ``` + */ + fun usageDiscountAdjustment(usageDiscount: Double) = + adjustment( + NewUsageDiscount.builder() + .adjustmentType(NewUsageDiscount.AdjustmentType.USAGE_DISCOUNT) + .usageDiscount(usageDiscount) + .build() + ) + + /** + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. + */ + fun adjustment(amountDiscount: NewAmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewAmountDiscount.builder() + * .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + * .amountDiscount(amountDiscount) + * .build() + * ``` + */ + fun amountDiscountAdjustment(amountDiscount: String) = + adjustment( + NewAmountDiscount.builder() + .adjustmentType(NewAmountDiscount.AdjustmentType.AMOUNT_DISCOUNT) + .amountDiscount(amountDiscount) + .build() + ) + + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: NewMinimum) = adjustment(Adjustment.ofMinimum(minimum)) + + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: NewMaximum) = adjustment(Adjustment.ofMaximum(maximum)) + + /** + * Alias for calling [adjustment] with the following: + * ```java + * NewMaximum.builder() + * .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + * .maximumAmount(maximumAmount) + * .build() + * ``` + */ + fun maximumAdjustment(maximumAmount: String) = + adjustment( + NewMaximum.builder() + .adjustmentType(NewMaximum.AdjustmentType.MAXIMUM) + .maximumAmount(maximumAmount) + .build() + ) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** + * Sets [Builder.replacesAdjustmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesAdjustmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { + this.replacesAdjustmentId = replacesAdjustmentId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplaceAdjustment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplaceAdjustment = + ReplaceAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ReplaceAdjustment = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (adjustment.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacesAdjustmentId.asKnown().isPresent) 1 else 0) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonDeserialize(using = Adjustment.Deserializer::class) + @JsonSerialize(using = Adjustment.Serializer::class) + class Adjustment + private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, + ) { + + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(maximum) + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = adjustment.accept(new Adjustment.Visitor>() { + * @Override + * public Optional visitPercentageDiscount(NewPercentageDiscount percentageDiscount) { + * return Optional.of(percentageDiscount.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + percentageDiscount != null -> + visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Adjustment = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) { + percentageDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) { + amountDiscount.validate() + } + + override fun visitMinimum(minimum: NewMinimum) { + minimum.validate() + } + + override fun visitMaximum(maximum: NewMaximum) { + maximum.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: NewPercentageDiscount + ) = percentageDiscount.validity() + + override fun visitUsageDiscount(usageDiscount: NewUsageDiscount) = + usageDiscount.validity() + + override fun visitAmountDiscount(amountDiscount: NewAmountDiscount) = + amountDiscount.validity() + + override fun visitMinimum(minimum: NewMinimum) = minimum.validity() + + override fun visitMaximum(maximum: NewMaximum) = maximum.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Adjustment && + percentageDiscount == other.percentageDiscount && + usageDiscount == other.usageDiscount && + amountDiscount == other.amountDiscount && + minimum == other.minimum && + maximum == other.maximum + } + + override fun hashCode(): Int = + Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) + + override fun toString(): String = + when { + percentageDiscount != null -> + "Adjustment{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "Adjustment{usageDiscount=$usageDiscount}" + amountDiscount != null -> "Adjustment{amountDiscount=$amountDiscount}" + minimum != null -> "Adjustment{minimum=$minimum}" + maximum != null -> "Adjustment{maximum=$maximum}" + _json != null -> "Adjustment{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Adjustment") + } + + companion object { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + Adjustment(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + Adjustment(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = Adjustment(minimum = minimum) + + @JvmStatic fun ofMaximum(maximum: NewMaximum) = Adjustment(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [Adjustment] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: NewPercentageDiscount): T + + fun visitUsageDiscount(usageDiscount: NewUsageDiscount): T + + fun visitAmountDiscount(amountDiscount: NewAmountDiscount): T + + fun visitMinimum(minimum: NewMinimum): T + + fun visitMaximum(maximum: NewMaximum): T + + /** + * Maps an unknown variant of [Adjustment] to a value of type [T]. + * + * An instance of [Adjustment] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Adjustment: $json") + } + } + + internal class Deserializer : BaseDeserializer(Adjustment::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + when (adjustmentType) { + "percentage_discount" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) + } + "usage_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "amount_discount" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) + } + "minimum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) + } + "maximum" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) + } + } + + return Adjustment(_json = json) + } + } + + internal class Serializer : BaseSerializer(Adjustment::class) { + + override fun serialize( + value: Adjustment, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> + generator.writeObject(value.percentageDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.minimum != null -> generator.writeObject(value.minimum) + value.maximum != null -> generator.writeObject(value.maximum) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Adjustment") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReplaceAdjustment && + adjustment == other.adjustment && + replacesAdjustmentId == other.replacesAdjustmentId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" + } + + class ReplacePrice + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val replacesPriceId: JsonField, + private val allocationPrice: JsonField, + private val discounts: JsonField>, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val maximumAmount: JsonField, + private val metricParameterOverrides: JsonField, + private val minimumAmount: JsonField, + private val price: JsonField, + private val priceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + metricParameterOverrides: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") @ExcludeMissing priceId: JsonField = JsonMissing.of(), + ) : this( + replacesPriceId, + allocationPrice, + discounts, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + metricParameterOverrides, + minimumAmount, + price, + priceId, + mutableMapOf(), + ) + + /** + * The id of the price on the plan to replace in the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * The definition of a new allocation price to create and add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allocationPrice(): Optional = + allocationPrice.getOptional("allocation_price") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun discounts(): Optional> = discounts.getOptional("discounts") + + /** + * The external price id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalPriceId(): Optional = externalPriceId.getOptional("external_price_id") + + /** + * The new quantity of the price, if the price is a fixed price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = maximumAmount.getOptional("maximum_amount") + + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metricParameterOverrides(): Optional = + metricParameterOverrides.getOptional("metric_parameter_overrides") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = minimumAmount.getOptional("minimum_amount") + + /** + * New subscription price request body params. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun price(): Optional = price.getOptional("price") + + /** + * The id of the price to add to the subscription. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun priceId(): Optional = priceId.getOptional("price_id") + + /** + * Returns the raw JSON value of [replacesPriceId]. + * + * Unlike [replacesPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** + * Returns the raw JSON value of [allocationPrice]. + * + * Unlike [allocationPrice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * Returns the raw JSON value of [discounts]. + * + * Unlike [discounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [maximumAmount]. + * + * Unlike [maximumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * Returns the raw JSON value of [metricParameterOverrides]. + * + * Unlike [metricParameterOverrides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metric_parameter_overrides") + @ExcludeMissing + fun _metricParameterOverrides(): JsonField = + metricParameterOverrides + + /** + * Returns the raw JSON value of [minimumAmount]. + * + * Unlike [minimumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [priceId]. + * + * Unlike [priceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReplacePrice]. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplacePrice]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var metricParameterOverrides: JsonField = + JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replacePrice: ReplacePrice) = apply { + replacesPriceId = replacePrice.replacesPriceId + allocationPrice = replacePrice.allocationPrice + discounts = replacePrice.discounts.map { it.toMutableList() } + externalPriceId = replacePrice.externalPriceId + fixedPriceQuantity = replacePrice.fixedPriceQuantity + maximumAmount = replacePrice.maximumAmount + metricParameterOverrides = replacePrice.metricParameterOverrides + minimumAmount = replacePrice.minimumAmount + price = replacePrice.price + priceId = replacePrice.priceId + additionalProperties = replacePrice.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** + * Sets [Builder.replacesPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.replacesPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { + this.replacesPriceId = replacesPriceId + } + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** Alias for calling [Builder.allocationPrice] with `allocationPrice.orElse(null)`. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.getOrNull()) + + /** + * Sets [Builder.allocationPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.allocationPrice] with a well-typed + * [NewAllocationPrice] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) + + /** Alias for calling [Builder.discounts] with `discounts.orElse(null)`. */ + @Deprecated("deprecated") + fun discounts(discounts: Optional>) = + discounts(discounts.getOrNull()) + + /** + * Sets [Builder.discounts] to an arbitrary JSON value. + * + * You should usually call [Builder.discounts] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * Adds a single [DiscountOverride] to [discounts]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverride) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Alias for calling [Builder.maximumAmount] with `maximumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.getOrNull()) + + /** + * Sets [Builder.maximumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * Override values for parameterized billable metric variables. Keys are parameter + * names, values are the override values. + */ + fun metricParameterOverrides(metricParameterOverrides: MetricParameterOverrides?) = + metricParameterOverrides(JsonField.ofNullable(metricParameterOverrides)) + + /** + * Alias for calling [Builder.metricParameterOverrides] with + * `metricParameterOverrides.orElse(null)`. + */ + fun metricParameterOverrides( + metricParameterOverrides: Optional + ) = metricParameterOverrides(metricParameterOverrides.getOrNull()) + + /** + * Sets [Builder.metricParameterOverrides] to an arbitrary JSON value. + * + * You should usually call [Builder.metricParameterOverrides] with a well-typed + * [MetricParameterOverrides] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metricParameterOverrides( + metricParameterOverrides: JsonField + ) = apply { this.metricParameterOverrides = metricParameterOverrides } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** Alias for calling [Builder.minimumAmount] with `minimumAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.getOrNull()) + + /** + * Sets [Builder.minimumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** New subscription price request body params. */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** Alias for calling [Builder.price] with `price.orElse(null)`. */ + fun price(price: Optional) = price(price.getOrNull()) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Price] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: NewSubscriptionUnitPrice) = price(Price.ofUnit(unit)) + + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: NewSubscriptionTieredPrice) = price(Price.ofTiered(tiered)) + + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: NewSubscriptionBulkPrice) = price(Price.ofBulk(bulk)) + + /** Alias for calling [price] with `Price.ofBulkWithFilters(bulkWithFilters)`. */ + fun price(bulkWithFilters: Price.BulkWithFilters) = + price(Price.ofBulkWithFilters(bulkWithFilters)) + + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: NewSubscriptionPackagePrice) = price(Price.ofPackage(package_)) + + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: NewSubscriptionMatrixPrice) = price(Price.ofMatrix(matrix)) + + /** + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. + */ + fun price(thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: NewSubscriptionTieredPackagePrice) = + price(Price.ofTieredPackage(tieredPackage)) + + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) + + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: NewSubscriptionGroupedTieredPrice) = + price(Price.ofGroupedTiered(groupedTiered)) + + /** + * Alias for calling [price] with + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. + */ + fun price(tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofPackageWithAllocation(packageWithAllocation)`. + */ + fun price(packageWithAllocation: NewSubscriptionPackageWithAllocationPrice) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) + + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + price(Price.ofUnitWithPercent(unitWithPercent)) + + /** + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. + */ + fun price(matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)`. + */ + fun price(matrixWithThresholdDiscounts: Price.MatrixWithThresholdDiscounts) = + price(Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts)) + + /** + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. + */ + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) + + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + price(Price.ofUnitWithProration(unitWithProration)) + + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + price(Price.ofGroupedAllocation(groupedAllocation)) + + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + price(Price.ofBulkWithProration(bulkWithProration)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. + */ + fun price(groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. + */ + fun price(groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + + /** + * Alias for calling [price] with + * `Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)`. + */ + fun price(groupedWithMinMaxThresholds: Price.GroupedWithMinMaxThresholds) = + price(Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds)) + + /** + * Alias for calling [price] with + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. + */ + fun price(matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + + /** + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. + */ + fun price(groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. + */ + fun price(maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun price( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + + /** + * Alias for calling [price] with + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun price( + scalableMatrixWithTieredPricing: NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. + */ + fun price(cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + + /** + * Alias for calling [price] with + * `Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)`. + */ + fun price(cumulativeGroupedAllocation: Price.CumulativeGroupedAllocation) = + price(Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation)) + + /** + * Alias for calling [price] with `Price.ofDailyCreditAllowance(dailyCreditAllowance)`. + */ + fun price(dailyCreditAllowance: Price.DailyCreditAllowance) = + price(Price.ofDailyCreditAllowance(dailyCreditAllowance)) + + /** Alias for calling [price] with `Price.ofMeteredAllowance(meteredAllowance)`. */ + fun price(meteredAllowance: Price.MeteredAllowance) = + price(Price.ofMeteredAllowance(meteredAllowance)) + + /** Alias for calling [price] with `Price.ofMinimumComposite(minimumComposite)`. */ + fun price(minimumComposite: NewSubscriptionMinimumCompositePrice) = + price(Price.ofMinimumComposite(minimumComposite)) + + /** Alias for calling [price] with `Price.ofPercent(percent)`. */ + fun price(percent: Price.Percent) = price(Price.ofPercent(percent)) + + /** Alias for calling [price] with `Price.ofEventOutput(eventOutput)`. */ + fun price(eventOutput: Price.EventOutput) = price(Price.ofEventOutput(eventOutput)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) + + /** + * Sets [Builder.priceId] to an arbitrary JSON value. + * + * You should usually call [Builder.priceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ReplacePrice]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReplacePrice = + ReplacePrice( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + metricParameterOverrides, + minimumAmount, + price, + priceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ReplacePrice = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice().ifPresent { it.validate() } + discounts().ifPresent { it.forEach { it.validate() } } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + metricParameterOverrides().ifPresent { it.validate() } + minimumAmount() + price().ifPresent { it.validate() } + priceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (replacesPriceId.asKnown().isPresent) 1 else 0) + + (allocationPrice.asKnown().getOrNull()?.validity() ?: 0) + + (discounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (maximumAmount.asKnown().isPresent) 1 else 0) + + (metricParameterOverrides.asKnown().getOrNull()?.validity() ?: 0) + + (if (minimumAmount.asKnown().isPresent) 1 else 0) + + (price.asKnown().getOrNull()?.validity() ?: 0) + + (if (priceId.asKnown().isPresent) 1 else 0) + + /** + * Override values for parameterized billable metric variables. Keys are parameter names, + * values are the override values. + */ + class MetricParameterOverrides + @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 + * [MetricParameterOverrides]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetricParameterOverrides]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metricParameterOverrides: MetricParameterOverrides) = apply { + additionalProperties = + metricParameterOverrides.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 [MetricParameterOverrides]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetricParameterOverrides = + MetricParameterOverrides(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): MetricParameterOverrides = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetricParameterOverrides && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MetricParameterOverrides{additionalProperties=$additionalProperties}" + } + + /** New subscription price request body params. */ + @JsonDeserialize(using = Price.Deserializer::class) + @JsonSerialize(using = Price.Serializer::class) + class Price + private constructor( + private val unit: NewSubscriptionUnitPrice? = null, + private val tiered: NewSubscriptionTieredPrice? = null, + private val bulk: NewSubscriptionBulkPrice? = null, + private val bulkWithFilters: BulkWithFilters? = null, + private val package_: NewSubscriptionPackagePrice? = null, + private val matrix: NewSubscriptionMatrixPrice? = null, + private val thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackage: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = null, + private val groupedTiered: NewSubscriptionGroupedTieredPrice? = null, + private val tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice? = + null, + private val packageWithAllocation: NewSubscriptionPackageWithAllocationPrice? = null, + private val unitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, + private val matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice? = null, + private val matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocation: NewSubscriptionGroupedAllocationPrice? = null, + private val bulkWithProration: NewSubscriptionBulkWithProrationPrice? = null, + private val groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds? = null, + private val matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice? = null, + private val maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val cumulativeGroupedAllocation: CumulativeGroupedAllocation? = null, + private val dailyCreditAllowance: DailyCreditAllowance? = null, + private val meteredAllowance: MeteredAllowance? = null, + private val minimumComposite: NewSubscriptionMinimumCompositePrice? = null, + private val percent: Percent? = null, + private val eventOutput: EventOutput? = null, + private val _json: JsonValue? = null, + ) { + + fun unit(): Optional = Optional.ofNullable(unit) + + fun tiered(): Optional = Optional.ofNullable(tiered) + + fun bulk(): Optional = Optional.ofNullable(bulk) + + fun bulkWithFilters(): Optional = Optional.ofNullable(bulkWithFilters) + + fun package_(): Optional = Optional.ofNullable(package_) + + fun matrix(): Optional = Optional.ofNullable(matrix) + + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) + + fun tieredPackage(): Optional = + Optional.ofNullable(tieredPackage) + + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) + + fun groupedTiered(): Optional = + Optional.ofNullable(groupedTiered) + + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) + + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) + + fun unitWithPercent(): Optional = + Optional.ofNullable(unitWithPercent) + + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) + + fun matrixWithThresholdDiscounts(): Optional = + Optional.ofNullable(matrixWithThresholdDiscounts) + + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) + + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) + + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) + + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) + + fun groupedWithProratedMinimum(): + Optional = + Optional.ofNullable(groupedWithProratedMinimum) + + fun groupedWithMeteredMinimum(): + Optional = + Optional.ofNullable(groupedWithMeteredMinimum) + + fun groupedWithMinMaxThresholds(): Optional = + Optional.ofNullable(groupedWithMinMaxThresholds) + + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) + + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) + + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) + + fun scalableMatrixWithUnitPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) + + fun scalableMatrixWithTieredPricing(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) + + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) + + fun cumulativeGroupedAllocation(): Optional = + Optional.ofNullable(cumulativeGroupedAllocation) + + fun dailyCreditAllowance(): Optional = + Optional.ofNullable(dailyCreditAllowance) + + fun meteredAllowance(): Optional = + Optional.ofNullable(meteredAllowance) + + fun minimumComposite(): Optional = + Optional.ofNullable(minimumComposite) + + fun percent(): Optional = Optional.ofNullable(percent) + + fun eventOutput(): Optional = Optional.ofNullable(eventOutput) + + fun isUnit(): Boolean = unit != null + + fun isTiered(): Boolean = tiered != null + + fun isBulk(): Boolean = bulk != null + + fun isBulkWithFilters(): Boolean = bulkWithFilters != null + + fun isPackage(): Boolean = package_ != null + + fun isMatrix(): Boolean = matrix != null + + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null + + fun isTieredPackage(): Boolean = tieredPackage != null + + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null + + fun isGroupedTiered(): Boolean = groupedTiered != null + + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null + + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null + + fun isUnitWithPercent(): Boolean = unitWithPercent != null + + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null + + fun isMatrixWithThresholdDiscounts(): Boolean = matrixWithThresholdDiscounts != null + + fun isTieredWithProration(): Boolean = tieredWithProration != null + + fun isUnitWithProration(): Boolean = unitWithProration != null + + fun isGroupedAllocation(): Boolean = groupedAllocation != null + + fun isBulkWithProration(): Boolean = bulkWithProration != null + + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null + + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null + + fun isGroupedWithMinMaxThresholds(): Boolean = groupedWithMinMaxThresholds != null + + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null + + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null + + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null + + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null + + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null + + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null + + fun isCumulativeGroupedAllocation(): Boolean = cumulativeGroupedAllocation != null + + fun isDailyCreditAllowance(): Boolean = dailyCreditAllowance != null + + fun isMeteredAllowance(): Boolean = meteredAllowance != null + + fun isMinimumComposite(): Boolean = minimumComposite != null + + fun isPercent(): Boolean = percent != null + + fun isEventOutput(): Boolean = eventOutput != null + + fun asUnit(): NewSubscriptionUnitPrice = unit.getOrThrow("unit") + + fun asTiered(): NewSubscriptionTieredPrice = tiered.getOrThrow("tiered") + + fun asBulk(): NewSubscriptionBulkPrice = bulk.getOrThrow("bulk") + + fun asBulkWithFilters(): BulkWithFilters = bulkWithFilters.getOrThrow("bulkWithFilters") + + fun asPackage(): NewSubscriptionPackagePrice = package_.getOrThrow("package_") + + fun asMatrix(): NewSubscriptionMatrixPrice = matrix.getOrThrow("matrix") + + fun asThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") + + fun asTieredPackage(): NewSubscriptionTieredPackagePrice = + tieredPackage.getOrThrow("tieredPackage") + + fun asTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimum.getOrThrow("tieredWithMinimum") + + fun asGroupedTiered(): NewSubscriptionGroupedTieredPrice = + groupedTiered.getOrThrow("groupedTiered") + + fun asTieredPackageWithMinimum(): NewSubscriptionTieredPackageWithMinimumPrice = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") + + fun asPackageWithAllocation(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocation.getOrThrow("packageWithAllocation") + + fun asUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = + unitWithPercent.getOrThrow("unitWithPercent") + + fun asMatrixWithAllocation(): NewSubscriptionMatrixWithAllocationPrice = + matrixWithAllocation.getOrThrow("matrixWithAllocation") + + fun asMatrixWithThresholdDiscounts(): MatrixWithThresholdDiscounts = + matrixWithThresholdDiscounts.getOrThrow("matrixWithThresholdDiscounts") + + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") + + fun asUnitWithProration(): NewSubscriptionUnitWithProrationPrice = + unitWithProration.getOrThrow("unitWithProration") + + fun asGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = + groupedAllocation.getOrThrow("groupedAllocation") + + fun asBulkWithProration(): NewSubscriptionBulkWithProrationPrice = + bulkWithProration.getOrThrow("bulkWithProration") + + fun asGroupedWithProratedMinimum(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") + + fun asGroupedWithMeteredMinimum(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") + + fun asGroupedWithMinMaxThresholds(): GroupedWithMinMaxThresholds = + groupedWithMinMaxThresholds.getOrThrow("groupedWithMinMaxThresholds") + + fun asMatrixWithDisplayName(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") + + fun asGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackage.getOrThrow("groupedTieredPackage") + + fun asMaxGroupTieredPackage(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") + + fun asScalableMatrixWithUnitPricing(): + NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") + + fun asScalableMatrixWithTieredPricing(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") + + fun asCumulativeGroupedBulk(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") + + fun asCumulativeGroupedAllocation(): CumulativeGroupedAllocation = + cumulativeGroupedAllocation.getOrThrow("cumulativeGroupedAllocation") + + fun asDailyCreditAllowance(): DailyCreditAllowance = + dailyCreditAllowance.getOrThrow("dailyCreditAllowance") + + fun asMeteredAllowance(): MeteredAllowance = + meteredAllowance.getOrThrow("meteredAllowance") + + fun asMinimumComposite(): NewSubscriptionMinimumCompositePrice = + minimumComposite.getOrThrow("minimumComposite") + + fun asPercent(): Percent = percent.getOrThrow("percent") + + fun asEventOutput(): EventOutput = eventOutput.getOrThrow("eventOutput") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = price.accept(new Price.Visitor>() { + * @Override + * public Optional visitUnit(NewSubscriptionUnitPrice unit) { + * return Optional.of(unit.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + unit != null -> visitor.visitUnit(unit) + tiered != null -> visitor.visitTiered(tiered) + bulk != null -> visitor.visitBulk(bulk) + bulkWithFilters != null -> visitor.visitBulkWithFilters(bulkWithFilters) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + groupedTiered != null -> visitor.visitGroupedTiered(groupedTiered) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + matrixWithAllocation != null -> + visitor.visitMatrixWithAllocation(matrixWithAllocation) + matrixWithThresholdDiscounts != null -> + visitor.visitMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + groupedWithMinMaxThresholds != null -> + visitor.visitGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + cumulativeGroupedAllocation != null -> + visitor.visitCumulativeGroupedAllocation(cumulativeGroupedAllocation) + dailyCreditAllowance != null -> + visitor.visitDailyCreditAllowance(dailyCreditAllowance) + meteredAllowance != null -> visitor.visitMeteredAllowance(meteredAllowance) + minimumComposite != null -> visitor.visitMinimumComposite(minimumComposite) + percent != null -> visitor.visitPercent(percent) + eventOutput != null -> visitor.visitEventOutput(eventOutput) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Price = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) { + unit.validate() + } + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) { + tiered.validate() + } + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) { + bulk.validate() + } + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) { + bulkWithFilters.validate() + } + + override fun visitPackage(package_: NewSubscriptionPackagePrice) { + package_.validate() + } + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) { + matrix.validate() + } + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmount.validate() + } + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) { + tieredPackage.validate() + } + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimum.validate() + } + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) { + groupedTiered.validate() + } + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimum.validate() + } + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocation.validate() + } + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercent.validate() + } + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) { + matrixWithAllocation.validate() + } + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) { + matrixWithThresholdDiscounts.validate() + } + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) { + tieredWithProration.validate() + } + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProration.validate() + } + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocation.validate() + } + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProration.validate() + } + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimum.validate() + } + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimum.validate() + } + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) { + groupedWithMinMaxThresholds.validate() + } + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayName.validate() + } + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackage.validate() + } + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackage.validate() + } + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricing.validate() + } + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricing.validate() + } + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulk.validate() + } + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) { + cumulativeGroupedAllocation.validate() + } + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) { + dailyCreditAllowance.validate() + } + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) { + meteredAllowance.validate() + } + + override fun visitMinimumComposite( + minimumComposite: NewSubscriptionMinimumCompositePrice + ) { + minimumComposite.validate() + } + + override fun visitPercent(percent: Percent) { + percent.validate() + } + + override fun visitEventOutput(eventOutput: EventOutput) { + eventOutput.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnit(unit: NewSubscriptionUnitPrice) = unit.validity() + + override fun visitTiered(tiered: NewSubscriptionTieredPrice) = + tiered.validity() + + override fun visitBulk(bulk: NewSubscriptionBulkPrice) = bulk.validity() + + override fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters) = + bulkWithFilters.validity() + + override fun visitPackage(package_: NewSubscriptionPackagePrice) = + package_.validity() + + override fun visitMatrix(matrix: NewSubscriptionMatrixPrice) = + matrix.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage( + tieredPackage: NewSubscriptionTieredPackagePrice + ) = tieredPackage.validity() + + override fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ) = tieredWithMinimum.validity() + + override fun visitGroupedTiered( + groupedTiered: NewSubscriptionGroupedTieredPrice + ) = groupedTiered.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = tieredPackageWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = packageWithAllocation.validity() + + override fun visitUnitWithPercent( + unitWithPercent: NewSubscriptionUnitWithPercentPrice + ) = unitWithPercent.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = matrixWithAllocation.validity() + + override fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = matrixWithThresholdDiscounts.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ) = unitWithProration.validity() + + override fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ) = groupedAllocation.validity() + + override fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ) = bulkWithProration.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = groupedWithMeteredMinimum.validity() + + override fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = groupedWithMinMaxThresholds.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = groupedTieredPackage.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = maxGroupTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = cumulativeGroupedBulk.validity() + + override fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = cumulativeGroupedAllocation.validity() + + override fun visitDailyCreditAllowance( + dailyCreditAllowance: DailyCreditAllowance + ) = dailyCreditAllowance.validity() + + override fun visitMeteredAllowance(meteredAllowance: MeteredAllowance) = + meteredAllowance.validity() + + override fun visitMinimumComposite( + minimumComposite: NewSubscriptionMinimumCompositePrice + ) = minimumComposite.validity() + + override fun visitPercent(percent: Percent) = percent.validity() + + override fun visitEventOutput(eventOutput: EventOutput) = + eventOutput.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Price && + unit == other.unit && + tiered == other.tiered && + bulk == other.bulk && + bulkWithFilters == other.bulkWithFilters && + package_ == other.package_ && + matrix == other.matrix && + thresholdTotalAmount == other.thresholdTotalAmount && + tieredPackage == other.tieredPackage && + tieredWithMinimum == other.tieredWithMinimum && + groupedTiered == other.groupedTiered && + tieredPackageWithMinimum == other.tieredPackageWithMinimum && + packageWithAllocation == other.packageWithAllocation && + unitWithPercent == other.unitWithPercent && + matrixWithAllocation == other.matrixWithAllocation && + matrixWithThresholdDiscounts == other.matrixWithThresholdDiscounts && + tieredWithProration == other.tieredWithProration && + unitWithProration == other.unitWithProration && + groupedAllocation == other.groupedAllocation && + bulkWithProration == other.bulkWithProration && + groupedWithProratedMinimum == other.groupedWithProratedMinimum && + groupedWithMeteredMinimum == other.groupedWithMeteredMinimum && + groupedWithMinMaxThresholds == other.groupedWithMinMaxThresholds && + matrixWithDisplayName == other.matrixWithDisplayName && + groupedTieredPackage == other.groupedTieredPackage && + maxGroupTieredPackage == other.maxGroupTieredPackage && + scalableMatrixWithUnitPricing == other.scalableMatrixWithUnitPricing && + scalableMatrixWithTieredPricing == other.scalableMatrixWithTieredPricing && + cumulativeGroupedBulk == other.cumulativeGroupedBulk && + cumulativeGroupedAllocation == other.cumulativeGroupedAllocation && + dailyCreditAllowance == other.dailyCreditAllowance && + meteredAllowance == other.meteredAllowance && + minimumComposite == other.minimumComposite && + percent == other.percent && + eventOutput == other.eventOutput + } + + override fun hashCode(): Int = + Objects.hash( + unit, + tiered, + bulk, + bulkWithFilters, + package_, + matrix, + thresholdTotalAmount, + tieredPackage, + tieredWithMinimum, + groupedTiered, + tieredPackageWithMinimum, + packageWithAllocation, + unitWithPercent, + matrixWithAllocation, + matrixWithThresholdDiscounts, + tieredWithProration, + unitWithProration, + groupedAllocation, + bulkWithProration, + groupedWithProratedMinimum, + groupedWithMeteredMinimum, + groupedWithMinMaxThresholds, + matrixWithDisplayName, + groupedTieredPackage, + maxGroupTieredPackage, + scalableMatrixWithUnitPricing, + scalableMatrixWithTieredPricing, + cumulativeGroupedBulk, + cumulativeGroupedAllocation, + dailyCreditAllowance, + meteredAllowance, + minimumComposite, + percent, + eventOutput, + ) + + override fun toString(): String = + when { + unit != null -> "Price{unit=$unit}" + tiered != null -> "Price{tiered=$tiered}" + bulk != null -> "Price{bulk=$bulk}" + bulkWithFilters != null -> "Price{bulkWithFilters=$bulkWithFilters}" + package_ != null -> "Price{package_=$package_}" + matrix != null -> "Price{matrix=$matrix}" + thresholdTotalAmount != null -> + "Price{thresholdTotalAmount=$thresholdTotalAmount}" + tieredPackage != null -> "Price{tieredPackage=$tieredPackage}" + tieredWithMinimum != null -> "Price{tieredWithMinimum=$tieredWithMinimum}" + groupedTiered != null -> "Price{groupedTiered=$groupedTiered}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + packageWithAllocation != null -> + "Price{packageWithAllocation=$packageWithAllocation}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + matrixWithAllocation != null -> + "Price{matrixWithAllocation=$matrixWithAllocation}" + matrixWithThresholdDiscounts != null -> + "Price{matrixWithThresholdDiscounts=$matrixWithThresholdDiscounts}" + tieredWithProration != null -> "Price{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Price{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Price{groupedAllocation=$groupedAllocation}" + bulkWithProration != null -> "Price{bulkWithProration=$bulkWithProration}" + groupedWithProratedMinimum != null -> + "Price{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Price{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + groupedWithMinMaxThresholds != null -> + "Price{groupedWithMinMaxThresholds=$groupedWithMinMaxThresholds}" + matrixWithDisplayName != null -> + "Price{matrixWithDisplayName=$matrixWithDisplayName}" + groupedTieredPackage != null -> + "Price{groupedTieredPackage=$groupedTieredPackage}" + maxGroupTieredPackage != null -> + "Price{maxGroupTieredPackage=$maxGroupTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" + cumulativeGroupedAllocation != null -> + "Price{cumulativeGroupedAllocation=$cumulativeGroupedAllocation}" + dailyCreditAllowance != null -> + "Price{dailyCreditAllowance=$dailyCreditAllowance}" + meteredAllowance != null -> "Price{meteredAllowance=$meteredAllowance}" + minimumComposite != null -> "Price{minimumComposite=$minimumComposite}" + percent != null -> "Price{percent=$percent}" + eventOutput != null -> "Price{eventOutput=$eventOutput}" + _json != null -> "Price{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Price") + } + + companion object { + + @JvmStatic fun ofUnit(unit: NewSubscriptionUnitPrice) = Price(unit = unit) + + @JvmStatic fun ofTiered(tiered: NewSubscriptionTieredPrice) = Price(tiered = tiered) + + @JvmStatic fun ofBulk(bulk: NewSubscriptionBulkPrice) = Price(bulk = bulk) + + @JvmStatic + fun ofBulkWithFilters(bulkWithFilters: BulkWithFilters) = + Price(bulkWithFilters = bulkWithFilters) + + @JvmStatic + fun ofPackage(package_: NewSubscriptionPackagePrice) = Price(package_ = package_) + + @JvmStatic fun ofMatrix(matrix: NewSubscriptionMatrixPrice) = Price(matrix = matrix) + + @JvmStatic + fun ofThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ) = Price(thresholdTotalAmount = thresholdTotalAmount) + + @JvmStatic + fun ofTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice) = + Price(tieredPackage = tieredPackage) + + @JvmStatic + fun ofTieredWithMinimum(tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice) = + Price(tieredWithMinimum = tieredWithMinimum) + + @JvmStatic + fun ofGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice) = + Price(groupedTiered = groupedTiered) + + @JvmStatic + fun ofTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) + + @JvmStatic + fun ofPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ) = Price(packageWithAllocation = packageWithAllocation) + + @JvmStatic + fun ofUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice) = + Price(unitWithPercent = unitWithPercent) + + @JvmStatic + fun ofMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ) = Price(matrixWithAllocation = matrixWithAllocation) + + @JvmStatic + fun ofMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ) = Price(matrixWithThresholdDiscounts = matrixWithThresholdDiscounts) + + @JvmStatic + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) + + @JvmStatic + fun ofUnitWithProration(unitWithProration: NewSubscriptionUnitWithProrationPrice) = + Price(unitWithProration = unitWithProration) + + @JvmStatic + fun ofGroupedAllocation(groupedAllocation: NewSubscriptionGroupedAllocationPrice) = + Price(groupedAllocation = groupedAllocation) + + @JvmStatic + fun ofBulkWithProration(bulkWithProration: NewSubscriptionBulkWithProrationPrice) = + Price(bulkWithProration = bulkWithProration) + + @JvmStatic + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + + @JvmStatic + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) + + @JvmStatic + fun ofGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ) = Price(groupedWithMinMaxThresholds = groupedWithMinMaxThresholds) + + @JvmStatic + fun ofMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ) = Price(matrixWithDisplayName = matrixWithDisplayName) + + @JvmStatic + fun ofGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ) = Price(groupedTieredPackage = groupedTieredPackage) + + @JvmStatic + fun ofMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ) = Price(maxGroupTieredPackage = maxGroupTieredPackage) + + @JvmStatic + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) + + @JvmStatic + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) + + @JvmStatic + fun ofCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) + + @JvmStatic + fun ofCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ) = Price(cumulativeGroupedAllocation = cumulativeGroupedAllocation) + + @JvmStatic + fun ofDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance) = + Price(dailyCreditAllowance = dailyCreditAllowance) + + @JvmStatic + fun ofMeteredAllowance(meteredAllowance: MeteredAllowance) = + Price(meteredAllowance = meteredAllowance) + + @JvmStatic + fun ofMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice) = + Price(minimumComposite = minimumComposite) + + @JvmStatic fun ofPercent(percent: Percent) = Price(percent = percent) + + @JvmStatic + fun ofEventOutput(eventOutput: EventOutput) = Price(eventOutput = eventOutput) + } + + /** + * An interface that defines how to map each variant of [Price] to a value of type [T]. + */ + interface Visitor { + + fun visitUnit(unit: NewSubscriptionUnitPrice): T + + fun visitTiered(tiered: NewSubscriptionTieredPrice): T + + fun visitBulk(bulk: NewSubscriptionBulkPrice): T + + fun visitBulkWithFilters(bulkWithFilters: BulkWithFilters): T + + fun visitPackage(package_: NewSubscriptionPackagePrice): T + + fun visitMatrix(matrix: NewSubscriptionMatrixPrice): T + + fun visitThresholdTotalAmount( + thresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackage(tieredPackage: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimum( + tieredWithMinimum: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitGroupedTiered(groupedTiered: NewSubscriptionGroupedTieredPrice): T + + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: NewSubscriptionTieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocation( + packageWithAllocation: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitUnitWithPercent(unitWithPercent: NewSubscriptionUnitWithPercentPrice): T + + fun visitMatrixWithAllocation( + matrixWithAllocation: NewSubscriptionMatrixWithAllocationPrice + ): T + + fun visitMatrixWithThresholdDiscounts( + matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts + ): T + + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T + + fun visitUnitWithProration( + unitWithProration: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocation( + groupedAllocation: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitBulkWithProration( + bulkWithProration: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitGroupedWithMinMaxThresholds( + groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds + ): T + + fun visitMatrixWithDisplayName( + matrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackage( + groupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice + ): T + + fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitCumulativeGroupedAllocation( + cumulativeGroupedAllocation: CumulativeGroupedAllocation + ): T + + fun visitDailyCreditAllowance(dailyCreditAllowance: DailyCreditAllowance): T + + fun visitMeteredAllowance(meteredAllowance: MeteredAllowance): T + + fun visitMinimumComposite(minimumComposite: NewSubscriptionMinimumCompositePrice): T + + fun visitPercent(percent: Percent): T + + fun visitEventOutput(eventOutput: EventOutput): T + + /** + * Maps an unknown variant of [Price] to a value of type [T]. + * + * An instance of [Price] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Price: $json") + } + } + + internal class Deserializer : BaseDeserializer(Price::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Price { + val json = JsonValue.fromJsonNode(node) + val modelType = + json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(unit = it, _json = json) } ?: Price(_json = json) + } + "tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) + } + "bulk" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) + } + "bulk_with_filters" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithFilters = it, _json = json) + } ?: Price(_json = json) + } + "package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(package_ = it, _json = json) } ?: Price(_json = json) + } + "matrix" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) + } + "threshold_total_amount" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTiered = it, _json = json) } + ?: Price(_json = json) + } + "tiered_package_with_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) + } + "package_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_percent" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithPercent = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithAllocation = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_threshold_discounts" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithThresholdDiscounts = it, _json = json) } + ?: Price(_json = json) + } + "tiered_with_proration" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } + ?: Price(_json = json) + } + "unit_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(unitWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "bulk_with_proration" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(bulkWithProration = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_prorated_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_metered_minimum" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) + } + "grouped_with_min_max_thresholds" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedWithMinMaxThresholds = it, _json = json) } + ?: Price(_json = json) + } + "matrix_with_display_name" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) + } + "grouped_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "max_group_tiered_package" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_unit_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithUnitPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) + } + "scalable_matrix_with_tiered_pricing" -> { + return tryDeserialize( + node, + jacksonTypeRef< + NewSubscriptionScalableMatrixWithTieredPricingPrice + >(), + ) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_bulk" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) + } + "cumulative_grouped_allocation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(cumulativeGroupedAllocation = it, _json = json) } + ?: Price(_json = json) + } + "daily_credit_allowance" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(dailyCreditAllowance = it, _json = json) } + ?: Price(_json = json) + } + "metered_allowance" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(meteredAllowance = it, _json = json) + } ?: Price(_json = json) + } + "minimum_composite" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Price(minimumComposite = it, _json = json) } + ?: Price(_json = json) + } + "percent" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(percent = it, _json = json) + } ?: Price(_json = json) + } + "event_output" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(eventOutput = it, _json = json) + } ?: Price(_json = json) + } + } + + return Price(_json = json) + } + } + + internal class Serializer : BaseSerializer(Price::class) { + + override fun serialize( + value: Price, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unit != null -> generator.writeObject(value.unit) + value.tiered != null -> generator.writeObject(value.tiered) + value.bulk != null -> generator.writeObject(value.bulk) + value.bulkWithFilters != null -> + generator.writeObject(value.bulkWithFilters) + value.package_ != null -> generator.writeObject(value.package_) + value.matrix != null -> generator.writeObject(value.matrix) + value.thresholdTotalAmount != null -> + generator.writeObject(value.thresholdTotalAmount) + value.tieredPackage != null -> generator.writeObject(value.tieredPackage) + value.tieredWithMinimum != null -> + generator.writeObject(value.tieredWithMinimum) + value.groupedTiered != null -> generator.writeObject(value.groupedTiered) + value.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.packageWithAllocation != null -> + generator.writeObject(value.packageWithAllocation) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + value.matrixWithAllocation != null -> + generator.writeObject(value.matrixWithAllocation) + value.matrixWithThresholdDiscounts != null -> + generator.writeObject(value.matrixWithThresholdDiscounts) + value.tieredWithProration != null -> + generator.writeObject(value.tieredWithProration) + value.unitWithProration != null -> + generator.writeObject(value.unitWithProration) + value.groupedAllocation != null -> + generator.writeObject(value.groupedAllocation) + value.bulkWithProration != null -> + generator.writeObject(value.bulkWithProration) + value.groupedWithProratedMinimum != null -> + generator.writeObject(value.groupedWithProratedMinimum) + value.groupedWithMeteredMinimum != null -> + generator.writeObject(value.groupedWithMeteredMinimum) + value.groupedWithMinMaxThresholds != null -> + generator.writeObject(value.groupedWithMinMaxThresholds) + value.matrixWithDisplayName != null -> + generator.writeObject(value.matrixWithDisplayName) + value.groupedTieredPackage != null -> + generator.writeObject(value.groupedTieredPackage) + value.maxGroupTieredPackage != null -> + generator.writeObject(value.maxGroupTieredPackage) + value.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) + value.cumulativeGroupedAllocation != null -> + generator.writeObject(value.cumulativeGroupedAllocation) + value.dailyCreditAllowance != null -> + generator.writeObject(value.dailyCreditAllowance) + value.meteredAllowance != null -> + generator.writeObject(value.meteredAllowance) + value.minimumComposite != null -> + generator.writeObject(value.minimumComposite) + value.percent != null -> generator.writeObject(value.percent) + value.eventOutput != null -> generator.writeObject(value.eventOutput) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Price") + } + } + } + + class BulkWithFilters + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val bulkWithFiltersConfig: JsonField, + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + bulkWithFiltersConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * Configuration for bulk_with_filters pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun bulkWithFiltersConfig(): BulkWithFiltersConfig = + bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [bulkWithFiltersConfig]. + * + * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("bulk_with_filters_config") + @ExcludeMissing + fun _bulkWithFiltersConfig(): JsonField = + bulkWithFiltersConfig + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFilters]. */ + class Builder internal constructor() { + + private var bulkWithFiltersConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_filters") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFilters: BulkWithFilters) = apply { + bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig + cadence = bulkWithFilters.cadence + itemId = bulkWithFilters.itemId + modelType = bulkWithFilters.modelType + name = bulkWithFilters.name + billableMetricId = bulkWithFilters.billableMetricId + billedInAdvance = bulkWithFilters.billedInAdvance + billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration + conversionRate = bulkWithFilters.conversionRate + conversionRateConfig = bulkWithFilters.conversionRateConfig + currency = bulkWithFilters.currency + dimensionalPriceConfiguration = + bulkWithFilters.dimensionalPriceConfiguration + externalPriceId = bulkWithFilters.externalPriceId + fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity + invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration + licenseTypeId = bulkWithFilters.licenseTypeId + metadata = bulkWithFilters.metadata + referenceId = bulkWithFilters.referenceId + additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + } + + /** Configuration for bulk_with_filters pricing */ + fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = + bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + + /** + * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed + * [BulkWithFiltersConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun bulkWithFiltersConfig( + bulkWithFiltersConfig: JsonField + ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_filters") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFilters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkWithFiltersConfig() + * .cadence() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFilters = + BulkWithFilters( + checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): BulkWithFilters = apply { + if (validated) { + return@apply + } + + bulkWithFiltersConfig().validate() + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("bulk_with_filters")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** Configuration for bulk_with_filters pricing */ + class BulkWithFiltersConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filters: JsonField>, + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + ) : this(filters, tiers, mutableMapOf()) + + /** + * Property filters to apply (all must match) + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun filters(): List = filters.getRequired("filters") + + /** + * Bulk tiers for rating based on total usage volume + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BulkWithFiltersConfig]. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithFiltersConfig]. */ + class Builder internal constructor() { + + private var filters: JsonField>? = null + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { + filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } + tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } + additionalProperties = + bulkWithFiltersConfig.additionalProperties.toMutableMap() + } + + /** Property filters to apply (all must match) */ + fun filters(filters: List) = filters(JsonField.of(filters)) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkWithFiltersConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filters() + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkWithFiltersConfig = + BulkWithFiltersConfig( + checkRequired("filters", filters).map { it.toImmutable() }, + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): BulkWithFiltersConfig = apply { + if (validated) { + return@apply + } + + filters().forEach { it.validate() } + tiers().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Configuration for a single property filter */ + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val propertyKey: JsonField, + private val propertyValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("property_key") + @ExcludeMissing + propertyKey: JsonField = JsonMissing.of(), + @JsonProperty("property_value") + @ExcludeMissing + propertyValue: JsonField = JsonMissing.of(), + ) : this(propertyKey, propertyValue, mutableMapOf()) + + /** + * Event property key to filter on + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyKey(): String = propertyKey.getRequired("property_key") + + /** + * Event property value to match + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun propertyValue(): String = propertyValue.getRequired("property_value") + + /** + * Returns the raw JSON value of [propertyKey]. + * + * Unlike [propertyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey + + /** + * Returns the raw JSON value of [propertyValue]. + * + * Unlike [propertyValue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + propertyKey = filter.propertyKey + propertyValue = filter.propertyValue + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Event property key to filter on */ + fun propertyKey(propertyKey: String) = + propertyKey(JsonField.of(propertyKey)) + + /** + * Sets [Builder.propertyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyKey] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyKey(propertyKey: JsonField) = apply { + this.propertyKey = propertyKey + } + + /** Event property value to match */ + fun propertyValue(propertyValue: String) = + propertyValue(JsonField.of(propertyValue)) + + /** + * Sets [Builder.propertyValue] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyValue] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun propertyValue(propertyValue: JsonField) = apply { + this.propertyValue = propertyValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("propertyKey", propertyKey), + checkRequired("propertyValue", propertyValue), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + propertyKey() + propertyValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (propertyKey.asKnown().isPresent) 1 else 0) + + (if (propertyValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + propertyKey == other.propertyKey && + propertyValue == other.propertyValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(propertyKey, propertyValue, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single bulk pricing tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val unitAmount: JsonField, + private val tierLowerBound: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + ) : this(unitAmount, tierLowerBound, mutableMapOf()) + + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * The lower bound for this tier + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tierLowerBound(): Optional = + tierLowerBound.getOptional("tier_lower_bound") + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var tierLowerBound: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + tierLowerBound = tier.tierLowerBound + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + /** The lower bound for this tier */ + fun tierLowerBound(tierLowerBound: String?) = + tierLowerBound(JsonField.ofNullable(tierLowerBound)) + + /** + * Alias for calling [Builder.tierLowerBound] with + * `tierLowerBound.orElse(null)`. + */ + fun tierLowerBound(tierLowerBound: Optional) = + tierLowerBound(tierLowerBound.getOrNull()) + + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + tierLowerBound, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + tierLowerBound() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + unitAmount == other.unitAmount && + tierLowerBound == other.tierLowerBound && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(unitAmount, tierLowerBound, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFiltersConfig && + filters == other.filters && + tiers == other.tiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filters, tiers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" + } + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkWithFilters && + bulkWithFiltersConfig == other.bulkWithFiltersConfig && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkWithFiltersConfig, + cadence, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class MatrixWithThresholdDiscounts + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val matrixWithThresholdDiscountsConfig: + JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + matrixWithThresholdDiscountsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * Configuration for matrix_with_threshold_discounts pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun matrixWithThresholdDiscountsConfig(): MatrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscountsConfig.getRequired( + "matrix_with_threshold_discounts_config" + ) + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_threshold_discounts") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [matrixWithThresholdDiscountsConfig]. + * + * Unlike [matrixWithThresholdDiscountsConfig], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("matrix_with_threshold_discounts_config") + @ExcludeMissing + fun _matrixWithThresholdDiscountsConfig(): + JsonField = + matrixWithThresholdDiscountsConfig + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscounts]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscounts]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithThresholdDiscountsConfig: + JsonField? = + null + private var modelType: JsonValue = + JsonValue.from("matrix_with_threshold_discounts") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithThresholdDiscounts: MatrixWithThresholdDiscounts) = + apply { + cadence = matrixWithThresholdDiscounts.cadence + itemId = matrixWithThresholdDiscounts.itemId + matrixWithThresholdDiscountsConfig = + matrixWithThresholdDiscounts.matrixWithThresholdDiscountsConfig + modelType = matrixWithThresholdDiscounts.modelType + name = matrixWithThresholdDiscounts.name + billableMetricId = matrixWithThresholdDiscounts.billableMetricId + billedInAdvance = matrixWithThresholdDiscounts.billedInAdvance + billingCycleConfiguration = + matrixWithThresholdDiscounts.billingCycleConfiguration + conversionRate = matrixWithThresholdDiscounts.conversionRate + conversionRateConfig = matrixWithThresholdDiscounts.conversionRateConfig + currency = matrixWithThresholdDiscounts.currency + dimensionalPriceConfiguration = + matrixWithThresholdDiscounts.dimensionalPriceConfiguration + externalPriceId = matrixWithThresholdDiscounts.externalPriceId + fixedPriceQuantity = matrixWithThresholdDiscounts.fixedPriceQuantity + invoiceGroupingKey = matrixWithThresholdDiscounts.invoiceGroupingKey + invoicingCycleConfiguration = + matrixWithThresholdDiscounts.invoicingCycleConfiguration + licenseTypeId = matrixWithThresholdDiscounts.licenseTypeId + metadata = matrixWithThresholdDiscounts.metadata + referenceId = matrixWithThresholdDiscounts.referenceId + additionalProperties = + matrixWithThresholdDiscounts.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** Configuration for matrix_with_threshold_discounts pricing */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = + matrixWithThresholdDiscountsConfig( + JsonField.of(matrixWithThresholdDiscountsConfig) + ) + + /** + * Sets [Builder.matrixWithThresholdDiscountsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixWithThresholdDiscountsConfig] with a + * well-typed [MatrixWithThresholdDiscountsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun matrixWithThresholdDiscountsConfig( + matrixWithThresholdDiscountsConfig: + JsonField + ) = apply { + this.matrixWithThresholdDiscountsConfig = matrixWithThresholdDiscountsConfig + } + + /** + * 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_with_threshold_discounts") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscounts]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithThresholdDiscountsConfig() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscounts = + MatrixWithThresholdDiscounts( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired( + "matrixWithThresholdDiscountsConfig", + matrixWithThresholdDiscountsConfig, + ), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MatrixWithThresholdDiscounts = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + matrixWithThresholdDiscountsConfig().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_threshold_discounts")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + (matrixWithThresholdDiscountsConfig.asKnown().getOrNull()?.validity() + ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_threshold_discounts")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val ONE_TIME = of("one_time") + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } + + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } + + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cadence && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration for matrix_with_threshold_discounts pricing */ + class MatrixWithThresholdDiscountsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val defaultUnitAmount: JsonField, + private val firstDimension: JsonField, + private val matrixValues: JsonField>, + private val secondDimension: JsonField, + private val thresholdDiscountGroups: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("default_unit_amount") + @ExcludeMissing + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("first_dimension") + @ExcludeMissing + firstDimension: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + @JsonProperty("second_dimension") + @ExcludeMissing + secondDimension: JsonField = JsonMissing.of(), + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + thresholdDiscountGroups: JsonField> = + JsonMissing.of(), + ) : this( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + mutableMapOf(), + ) + + /** + * Unit price used for usage that does not match any defined matrix cell. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** + * First matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun firstDimension(): String = firstDimension.getRequired("first_dimension") + + /** + * Per-cell unit prices. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Optional second matrix dimension key. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimension(): Optional = + secondDimension.getOptional("second_dimension") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun thresholdDiscountGroups(): Optional> = + thresholdDiscountGroups.getOptional("threshold_discount_groups") + + /** + * Returns the raw JSON value of [defaultUnitAmount]. + * + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [firstDimension]. + * + * Unlike [firstDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("first_dimension") + @ExcludeMissing + fun _firstDimension(): JsonField = firstDimension + + /** + * Returns the raw JSON value of [matrixValues]. + * + * Unlike [matrixValues], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + /** + * Returns the raw JSON value of [secondDimension]. + * + * Unlike [secondDimension], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("second_dimension") + @ExcludeMissing + fun _secondDimension(): JsonField = secondDimension + + /** + * Returns the raw JSON value of [thresholdDiscountGroups]. + * + * Unlike [thresholdDiscountGroups], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("threshold_discount_groups") + @ExcludeMissing + fun _thresholdDiscountGroups(): JsonField> = + thresholdDiscountGroups + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithThresholdDiscountsConfig]. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithThresholdDiscountsConfig]. */ + class Builder internal constructor() { + + private var defaultUnitAmount: JsonField? = null + private var firstDimension: JsonField? = null + private var matrixValues: JsonField>? = null + private var secondDimension: JsonField = JsonMissing.of() + private var thresholdDiscountGroups: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + matrixWithThresholdDiscountsConfig: MatrixWithThresholdDiscountsConfig + ) = apply { + defaultUnitAmount = matrixWithThresholdDiscountsConfig.defaultUnitAmount + firstDimension = matrixWithThresholdDiscountsConfig.firstDimension + matrixValues = + matrixWithThresholdDiscountsConfig.matrixValues.map { + it.toMutableList() + } + secondDimension = matrixWithThresholdDiscountsConfig.secondDimension + thresholdDiscountGroups = + matrixWithThresholdDiscountsConfig.thresholdDiscountGroups.map { + it.toMutableList() + } + additionalProperties = + matrixWithThresholdDiscountsConfig.additionalProperties + .toMutableMap() + } + + /** + * Unit price used for usage that does not match any defined matrix cell. + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultUnitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount + } + + /** First matrix dimension key. */ + fun firstDimension(firstDimension: String) = + firstDimension(JsonField.of(firstDimension)) + + /** + * Sets [Builder.firstDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun firstDimension(firstDimension: JsonField) = apply { + this.firstDimension = firstDimension + } + + /** Per-cell unit prices. */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** + * Sets [Builder.matrixValues] to an arbitrary JSON value. + * + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + /** Optional second matrix dimension key. */ + fun secondDimension(secondDimension: String?) = + secondDimension(JsonField.ofNullable(secondDimension)) + + /** + * Alias for calling [Builder.secondDimension] with + * `secondDimension.orElse(null)`. + */ + fun secondDimension(secondDimension: Optional) = + secondDimension(secondDimension.getOrNull()) + + /** + * Sets [Builder.secondDimension] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimension] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun secondDimension(secondDimension: JsonField) = apply { + this.secondDimension = secondDimension + } + + fun thresholdDiscountGroups( + thresholdDiscountGroups: List + ) = thresholdDiscountGroups(JsonField.of(thresholdDiscountGroups)) + + /** + * Sets [Builder.thresholdDiscountGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdDiscountGroups] with a + * well-typed `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thresholdDiscountGroups( + thresholdDiscountGroups: JsonField> + ) = apply { + this.thresholdDiscountGroups = + thresholdDiscountGroups.map { it.toMutableList() } + } + + /** + * Adds a single [ThresholdDiscountGroup] to [thresholdDiscountGroups]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addThresholdDiscountGroup( + thresholdDiscountGroup: ThresholdDiscountGroup + ) = apply { + thresholdDiscountGroups = + (thresholdDiscountGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholdDiscountGroups", it) + .add(thresholdDiscountGroup) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixWithThresholdDiscountsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .firstDimension() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixWithThresholdDiscountsConfig = + MatrixWithThresholdDiscountsConfig( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("firstDimension", firstDimension), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + secondDimension, + (thresholdDiscountGroups ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixWithThresholdDiscountsConfig = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + firstDimension() + matrixValues().forEach { it.validate() } + secondDimension() + thresholdDiscountGroups().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (if (firstDimension.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (secondDimension.asKnown().isPresent) 1 else 0) + + (thresholdDiscountGroups.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val firstDimensionValue: JsonField, + private val unitAmount: JsonField, + private val secondDimensionValue: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("first_dimension_value") + @ExcludeMissing + firstDimensionValue: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("second_dimension_value") + @ExcludeMissing + secondDimensionValue: JsonField = JsonMissing.of(), + ) : this( + firstDimensionValue, + unitAmount, + secondDimensionValue, + 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 firstDimensionValue(): String = + firstDimensionValue.getRequired("first_dimension_value") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun secondDimensionValue(): Optional = + secondDimensionValue.getOptional("second_dimension_value") + + /** + * Returns the raw JSON value of [firstDimensionValue]. + * + * Unlike [firstDimensionValue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("first_dimension_value") + @ExcludeMissing + fun _firstDimensionValue(): JsonField = firstDimensionValue + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** + * Returns the raw JSON value of [secondDimensionValue]. + * + * Unlike [secondDimensionValue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("second_dimension_value") + @ExcludeMissing + fun _secondDimensionValue(): JsonField = secondDimensionValue + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var firstDimensionValue: JsonField? = null + private var unitAmount: JsonField? = null + private var secondDimensionValue: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + firstDimensionValue = matrixValue.firstDimensionValue + unitAmount = matrixValue.unitAmount + secondDimensionValue = matrixValue.secondDimensionValue + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + fun firstDimensionValue(firstDimensionValue: String) = + firstDimensionValue(JsonField.of(firstDimensionValue)) + + /** + * Sets [Builder.firstDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.firstDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun firstDimensionValue(firstDimensionValue: JsonField) = + apply { + this.firstDimensionValue = firstDimensionValue + } + + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun secondDimensionValue(secondDimensionValue: String?) = + secondDimensionValue(JsonField.ofNullable(secondDimensionValue)) + + /** + * Alias for calling [Builder.secondDimensionValue] with + * `secondDimensionValue.orElse(null)`. + */ + fun secondDimensionValue(secondDimensionValue: Optional) = + secondDimensionValue(secondDimensionValue.getOrNull()) + + /** + * Sets [Builder.secondDimensionValue] to an arbitrary JSON value. + * + * You should usually call [Builder.secondDimensionValue] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun secondDimensionValue(secondDimensionValue: JsonField) = + apply { + this.secondDimensionValue = secondDimensionValue + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .firstDimensionValue() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("firstDimensionValue", firstDimensionValue), + checkRequired("unitAmount", unitAmount), + secondDimensionValue, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + firstDimensionValue() + unitAmount() + secondDimensionValue() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (firstDimensionValue.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (secondDimensionValue.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + firstDimensionValue == other.firstDimensionValue && + unitAmount == other.unitAmount && + secondDimensionValue == other.secondDimensionValue && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + firstDimensionValue, + unitAmount, + secondDimensionValue, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{firstDimensionValue=$firstDimensionValue, unitAmount=$unitAmount, secondDimensionValue=$secondDimensionValue, additionalProperties=$additionalProperties}" + } + + class ThresholdDiscountGroup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val aboveThresholdDiscountPercentage: JsonField, + private val belowThresholdDiscountPercentage: JsonField, + private val cellCoordinates: JsonField, + private val thresholdAmount: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + aboveThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + belowThresholdDiscountPercentage: JsonField = JsonMissing.of(), + @JsonProperty("cell_coordinates") + @ExcludeMissing + cellCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("threshold_amount") + @ExcludeMissing + thresholdAmount: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + mutableMapOf(), + ) + + /** + * Discount rate applied to spend above the threshold. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun aboveThresholdDiscountPercentage(): String = + aboveThresholdDiscountPercentage.getRequired( + "above_threshold_discount_percentage" + ) + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 for no + * baseline discount. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun belowThresholdDiscountPercentage(): String = + belowThresholdDiscountPercentage.getRequired( + "below_threshold_discount_percentage" + ) + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun cellCoordinates(): String = + cellCoordinates.getRequired("cell_coordinates") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun thresholdAmount(): String = + thresholdAmount.getRequired("threshold_amount") + + /** + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [aboveThresholdDiscountPercentage]. + * + * Unlike [aboveThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("above_threshold_discount_percentage") + @ExcludeMissing + fun _aboveThresholdDiscountPercentage(): JsonField = + aboveThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [belowThresholdDiscountPercentage]. + * + * Unlike [belowThresholdDiscountPercentage], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("below_threshold_discount_percentage") + @ExcludeMissing + fun _belowThresholdDiscountPercentage(): JsonField = + belowThresholdDiscountPercentage + + /** + * Returns the raw JSON value of [cellCoordinates]. + * + * Unlike [cellCoordinates], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cell_coordinates") + @ExcludeMissing + fun _cellCoordinates(): JsonField = cellCoordinates + + /** + * Returns the raw JSON value of [thresholdAmount]. + * + * Unlike [thresholdAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("threshold_amount") + @ExcludeMissing + fun _thresholdAmount(): JsonField = thresholdAmount + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdDiscountGroup]. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdDiscountGroup]. */ + class Builder internal constructor() { + + private var aboveThresholdDiscountPercentage: JsonField? = null + private var belowThresholdDiscountPercentage: JsonField? = null + private var cellCoordinates: JsonField? = null + private var thresholdAmount: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdDiscountGroup: ThresholdDiscountGroup) = + apply { + aboveThresholdDiscountPercentage = + thresholdDiscountGroup.aboveThresholdDiscountPercentage + belowThresholdDiscountPercentage = + thresholdDiscountGroup.belowThresholdDiscountPercentage + cellCoordinates = thresholdDiscountGroup.cellCoordinates + thresholdAmount = thresholdDiscountGroup.thresholdAmount + description = thresholdDiscountGroup.description + additionalProperties = + thresholdDiscountGroup.additionalProperties.toMutableMap() + } + + /** Discount rate applied to spend above the threshold. */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: String + ) = + aboveThresholdDiscountPercentage( + JsonField.of(aboveThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.aboveThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.aboveThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun aboveThresholdDiscountPercentage( + aboveThresholdDiscountPercentage: JsonField + ) = apply { + this.aboveThresholdDiscountPercentage = + aboveThresholdDiscountPercentage + } + + /** + * Discount rate applied to spend at or below the threshold. Set to 0 + * for no baseline discount. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: String + ) = + belowThresholdDiscountPercentage( + JsonField.of(belowThresholdDiscountPercentage) + ) + + /** + * Sets [Builder.belowThresholdDiscountPercentage] to an arbitrary JSON + * value. + * + * You should usually call [Builder.belowThresholdDiscountPercentage] + * with a well-typed [String] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun belowThresholdDiscountPercentage( + belowThresholdDiscountPercentage: JsonField + ) = apply { + this.belowThresholdDiscountPercentage = + belowThresholdDiscountPercentage + } + + /** + * Semicolon-separated list of matrix cell coordinates targeted by this + * group. Each coordinate is `first,second` when the matrix has two + * dimensions, or just `first` for a single-dimension matrix. Example: + * `blue,circle;green,triangle`. + */ + fun cellCoordinates(cellCoordinates: String) = + cellCoordinates(JsonField.of(cellCoordinates)) + + /** + * Sets [Builder.cellCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.cellCoordinates] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cellCoordinates(cellCoordinates: JsonField) = apply { + this.cellCoordinates = cellCoordinates + } + + fun thresholdAmount(thresholdAmount: String) = + thresholdAmount(JsonField.of(thresholdAmount)) + + /** + * Sets [Builder.thresholdAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholdAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thresholdAmount(thresholdAmount: JsonField) = apply { + this.thresholdAmount = thresholdAmount + } + + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** + * Alias for calling [Builder.description] with + * `description.orElse(null)`. + */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ThresholdDiscountGroup]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .aboveThresholdDiscountPercentage() + * .belowThresholdDiscountPercentage() + * .cellCoordinates() + * .thresholdAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThresholdDiscountGroup = + ThresholdDiscountGroup( + checkRequired( + "aboveThresholdDiscountPercentage", + aboveThresholdDiscountPercentage, + ), + checkRequired( + "belowThresholdDiscountPercentage", + belowThresholdDiscountPercentage, + ), + checkRequired("cellCoordinates", cellCoordinates), + checkRequired("thresholdAmount", thresholdAmount), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): ThresholdDiscountGroup = apply { + if (validated) { + return@apply + } + + aboveThresholdDiscountPercentage() + belowThresholdDiscountPercentage() + cellCoordinates() + thresholdAmount() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (aboveThresholdDiscountPercentage.asKnown().isPresent) 1 else 0) + + (if (belowThresholdDiscountPercentage.asKnown().isPresent) 1 + else 0) + + (if (cellCoordinates.asKnown().isPresent) 1 else 0) + + (if (thresholdAmount.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThresholdDiscountGroup && + aboveThresholdDiscountPercentage == + other.aboveThresholdDiscountPercentage && + belowThresholdDiscountPercentage == + other.belowThresholdDiscountPercentage && + cellCoordinates == other.cellCoordinates && + thresholdAmount == other.thresholdAmount && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboveThresholdDiscountPercentage, + belowThresholdDiscountPercentage, + cellCoordinates, + thresholdAmount, + description, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdDiscountGroup{aboveThresholdDiscountPercentage=$aboveThresholdDiscountPercentage, belowThresholdDiscountPercentage=$belowThresholdDiscountPercentage, cellCoordinates=$cellCoordinates, thresholdAmount=$thresholdAmount, description=$description, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscountsConfig && + defaultUnitAmount == other.defaultUnitAmount && + firstDimension == other.firstDimension && + matrixValues == other.matrixValues && + secondDimension == other.secondDimension && + thresholdDiscountGroups == other.thresholdDiscountGroups && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultUnitAmount, + firstDimension, + matrixValues, + secondDimension, + thresholdDiscountGroups, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscountsConfig{defaultUnitAmount=$defaultUnitAmount, firstDimension=$firstDimension, matrixValues=$matrixValues, secondDimension=$secondDimension, thresholdDiscountGroups=$thresholdDiscountGroups, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixWithThresholdDiscounts && + cadence == other.cadence && + itemId == other.itemId && + matrixWithThresholdDiscountsConfig == + other.matrixWithThresholdDiscountsConfig && + modelType == other.modelType && + name == other.name && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + matrixWithThresholdDiscountsConfig, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithThresholdDiscounts{cadence=$cadence, itemId=$itemId, matrixWithThresholdDiscountsConfig=$matrixWithThresholdDiscountsConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + class TieredWithProration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val tieredWithProrationConfig: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) + + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * Configuration for tiered_with_proration pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") + + /** + * The configuration for the rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") + + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") + + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [tieredWithProrationConfig]. + * + * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProration]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProration]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + conversionRateConfig = tieredWithProration.conversionRateConfig + currency = tieredWithProration.currency + dimensionalPriceConfiguration = + tieredWithProration.dimensionalPriceConfiguration + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = + tieredWithProration.invoicingCycleConfiguration + licenseTypeId = tieredWithProration.licenseTypeId + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId + additionalProperties = + tieredWithProration.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Configuration for tiered_with_proration pricing */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + /** + * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.tieredWithProrationConfig] with a well-typed + * [TieredWithProrationConfig] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) + + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) + + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) + + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) + + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) + + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) + + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) + + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) + + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) + + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) + + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) + + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) + + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredWithProration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .name() + * .tieredWithProrationConfig() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProration = + TieredWithProration( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): TieredWithProration = apply { + if (validated) { + return@apply + } + + cadence().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) + + /** The cadence to bill for this price on. */ + class Cadence + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ANNUAL = of("annual") - /** - * Configuration for bulk_with_filters pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun bulkWithFiltersConfig(): BulkWithFiltersConfig = - bulkWithFiltersConfig.getRequired("bulk_with_filters_config") + @JvmField val SEMI_ANNUAL = of("semi_annual") - /** - * The cadence to bill for this price on. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun cadence(): Cadence = cadence.getRequired("cadence") + @JvmField val MONTHLY = of("monthly") - /** - * The id of the item the price will be associated with. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun itemId(): String = itemId.getRequired("item_id") + @JvmField val QUARTERLY = of("quarterly") - /** - * The pricing model type - * - * Expected to always return the following: - * ```java - * JsonValue.from("bulk_with_filters") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType + @JvmField val ONE_TIME = of("one_time") - /** - * The name of the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") + @JvmField val CUSTOM = of("custom") - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billableMetricId(): Optional = - billableMetricId.getOptional("billable_metric_id") + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billedInAdvance(): Optional = - billedInAdvance.getOptional("billed_in_advance") + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun billingCycleConfiguration(): Optional = - billingCycleConfiguration.getOptional("billing_cycle_configuration") + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - /** - * The per unit conversion rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRate(): Optional = - conversionRate.getOptional("conversion_rate") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } - /** - * The configuration for the rate of the price currency to the invoicing currency. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun conversionRateConfig(): Optional = - conversionRateConfig.getOptional("conversion_rate_config") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * For dimensional price: specifies a price group and dimension values - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dimensionalPriceConfiguration(): Optional = - dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") + private var validated: Boolean = false - /** - * An alias for the price. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun externalPriceId(): Optional = - externalPriceId.getOptional("external_price_id") + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Cadence = apply { + if (validated) { + return@apply + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun fixedPriceQuantity(): Optional = - fixedPriceQuantity.getOptional("fixed_price_quantity") + known() + validated = true + } - /** - * The property used to group this price on an invoice - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoiceGroupingKey(): Optional = - invoiceGroupingKey.getOptional("invoice_grouping_key") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun invoicingCycleConfiguration(): Optional = - invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun referenceId(): Optional = referenceId.getOptional("reference_id") + return other is Cadence && value == other.value + } - /** - * Returns the raw JSON value of [bulkWithFiltersConfig]. - * - * Unlike [bulkWithFiltersConfig], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("bulk_with_filters_config") - @ExcludeMissing - fun _bulkWithFiltersConfig(): JsonField = - bulkWithFiltersConfig + override fun hashCode() = value.hashCode() - /** - * Returns the raw JSON value of [cadence]. - * - * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence + override fun toString() = value.toString() + } - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** Configuration for tiered_with_proration pricing */ + class TieredWithProrationConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tiers: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonCreator + private constructor( + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of() + ) : this(tiers, mutableMapOf()) - /** - * Returns the raw JSON value of [billableMetricId]. - * - * Unlike [billableMetricId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** + * Tiers for rating based on total usage quantities into the specified tier with + * proration + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tiers(): List = tiers.getRequired("tiers") - /** - * Returns the raw JSON value of [billedInAdvance]. - * - * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers - /** - * Returns the raw JSON value of [billingCycleConfiguration]. - * - * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [conversionRate]. - * - * Unlike [conversionRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw JSON value of [conversionRateConfig]. - * - * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversion_rate_config") - @ExcludeMissing - fun _conversionRateConfig(): JsonField = conversionRateConfig + fun toBuilder() = Builder().from(this) - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency + companion object { - /** - * Returns the raw JSON value of [dimensionalPriceConfiguration]. - * - * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration + /** + * Returns a mutable builder for constructing an instance of + * [TieredWithProrationConfig]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [externalPriceId]. - * - * Unlike [externalPriceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** A builder for [TieredWithProrationConfig]. */ + class Builder internal constructor() { - /** - * Returns the raw JSON value of [fixedPriceQuantity]. - * - * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Returns the raw JSON value of [invoiceGroupingKey]. - * - * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + @JvmSynthetic + internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = + apply { + tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } + additionalProperties = + tieredWithProrationConfig.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [invoicingCycleConfiguration]. - * - * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** + * Tiers for rating based on total usage quantities into the specified tier + * with proration + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Returns the raw JSON value of [referenceId]. - * - * Unlike [referenceId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun toBuilder() = Builder().from(this) + /** + * Returns an immutable instance of [TieredWithProrationConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TieredWithProrationConfig = + TieredWithProrationConfig( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - companion object { + private var validated: Boolean = false /** - * Returns a mutable builder for constructing an instance of [BulkWithFilters]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithFilters]. */ - class Builder internal constructor() { - - private var bulkWithFiltersConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("bulk_with_filters") - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var conversionRateConfig: JsonField = - JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var dimensionalPriceConfiguration: - JsonField = - JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): TieredWithProrationConfig = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(bulkWithFilters: BulkWithFilters) = apply { - bulkWithFiltersConfig = bulkWithFilters.bulkWithFiltersConfig - cadence = bulkWithFilters.cadence - itemId = bulkWithFilters.itemId - modelType = bulkWithFilters.modelType - name = bulkWithFilters.name - billableMetricId = bulkWithFilters.billableMetricId - billedInAdvance = bulkWithFilters.billedInAdvance - billingCycleConfiguration = bulkWithFilters.billingCycleConfiguration - conversionRate = bulkWithFilters.conversionRate - conversionRateConfig = bulkWithFilters.conversionRateConfig - currency = bulkWithFilters.currency - dimensionalPriceConfiguration = - bulkWithFilters.dimensionalPriceConfiguration - externalPriceId = bulkWithFilters.externalPriceId - fixedPriceQuantity = bulkWithFilters.fixedPriceQuantity - invoiceGroupingKey = bulkWithFilters.invoiceGroupingKey - invoicingCycleConfiguration = bulkWithFilters.invoicingCycleConfiguration - metadata = bulkWithFilters.metadata - referenceId = bulkWithFilters.referenceId - additionalProperties = bulkWithFilters.additionalProperties.toMutableMap() + tiers().forEach { it.validate() } + validated = true } - /** Configuration for bulk_with_filters pricing */ - fun bulkWithFiltersConfig(bulkWithFiltersConfig: BulkWithFiltersConfig) = - bulkWithFiltersConfig(JsonField.of(bulkWithFiltersConfig)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.bulkWithFiltersConfig] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.bulkWithFiltersConfig] with a well-typed - * [BulkWithFiltersConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun bulkWithFiltersConfig( - bulkWithFiltersConfig: JsonField - ) = apply { this.bulkWithFiltersConfig = bulkWithFiltersConfig } + @JvmSynthetic + internal fun validity(): Int = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + /** Configuration for a single tiered with proration tier */ + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tierLowerBound: JsonField, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.cadence] to an arbitrary JSON value. - * - * You should usually call [Builder.cadence] with a well-typed [Cadence] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + @JsonCreator + private constructor( + @JsonProperty("tier_lower_bound") + @ExcludeMissing + tierLowerBound: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(tierLowerBound, unitAmount, mutableMapOf()) - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Inclusive tier starting value + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun tierLowerBound(): String = + tierLowerBound.getRequired("tier_lower_bound") - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * Amount per unit + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") - /** - * 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("bulk_with_filters") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } + /** + * Returns the raw JSON value of [tierLowerBound]. + * + * Unlike [tierLowerBound], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("tier_lower_bound") + @ExcludeMissing + fun _tierLowerBound(): JsonField = tierLowerBound - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for calling [Builder.billableMetricId] with - * `billableMetricId.orElse(null)`. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.getOrNull()) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.billableMetricId] to an arbitrary JSON value. - * - * You should usually call [Builder.billableMetricId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId - } + companion object { - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for [Builder.billedInAdvance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + /** A builder for [Tier]. */ + class Builder internal constructor() { - /** - * Alias for calling [Builder.billedInAdvance] with - * `billedInAdvance.orElse(null)`. - */ - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.getOrNull()) + private var tierLowerBound: JsonField? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() - /** - * Sets [Builder.billedInAdvance] to an arbitrary JSON value. - * - * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } + @JvmSynthetic + internal fun from(tier: Tier) = apply { + tierLowerBound = tier.tierLowerBound + unitAmount = tier.unitAmount + additionalProperties = tier.additionalProperties.toMutableMap() + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: NewBillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + /** Inclusive tier starting value */ + fun tierLowerBound(tierLowerBound: String) = + tierLowerBound(JsonField.of(tierLowerBound)) - /** - * Alias for calling [Builder.billingCycleConfiguration] with - * `billingCycleConfiguration.orElse(null)`. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) + /** + * Sets [Builder.tierLowerBound] to an arbitrary JSON value. + * + * You should usually call [Builder.tierLowerBound] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tierLowerBound(tierLowerBound: JsonField) = apply { + this.tierLowerBound = tierLowerBound + } - /** - * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.billingCycleConfiguration] with a well-typed - * [NewBillingCycleConfiguration] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } - /** - * Alias for [Builder.conversionRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Alias for calling [Builder.conversionRate] with - * `conversionRate.orElse(null)`. - */ - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.getOrNull()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.conversionRate] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRate] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tier]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .tierLowerBound() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("tierLowerBound", tierLowerBound), + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + tierLowerBound() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tierLowerBound.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + tierLowerBound == other.tierLowerBound && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tierLowerBound, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TieredWithProrationConfig && + tiers == other.tiers && + additionalProperties == other.additionalProperties } - /** - * The configuration for the rate of the price currency to the invoicing - * currency. - */ - fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = - conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /** - * Alias for calling [Builder.conversionRateConfig] with - * `conversionRateConfig.orElse(null)`. - */ - fun conversionRateConfig(conversionRateConfig: Optional) = - conversionRateConfig(conversionRateConfig.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.conversionRateConfig] with a well-typed - * [ConversionRateConfig] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun conversionRateConfig( - conversionRateConfig: JsonField - ) = apply { this.conversionRateConfig = conversionRateConfig } + override fun toString() = + "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + } - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofUnit(unit)`. - */ - fun conversionRateConfig(unit: UnitConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofUnit(unit)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * UnitConversionRateConfig.builder() - * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) - * .unitConfig(unitConfig) - * .build() - * ``` - */ - fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = - conversionRateConfig( - UnitConversionRateConfig.builder() - .conversionRateType( - UnitConversionRateConfig.ConversionRateType.UNIT - ) - .unitConfig(unitConfig) - .build() - ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Alias for calling [conversionRateConfig] with - * `ConversionRateConfig.ofTiered(tiered)`. - */ - fun conversionRateConfig(tiered: TieredConversionRateConfig) = - conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) + fun toBuilder() = Builder().from(this) - /** - * Alias for calling [conversionRateConfig] with the following: - * ```java - * TieredConversionRateConfig.builder() - * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) - * .tieredConfig(tieredConfig) - * .build() - * ``` - */ - fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = - conversionRateConfig( - TieredConversionRateConfig.builder() - .conversionRateType( - TieredConversionRateConfig.ConversionRateType.TIERED - ) - .tieredConfig(tieredConfig) - .build() - ) + companion object { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + private var additionalProperties: MutableMap = + mutableMapOf() - /** For dimensional price: specifies a price group and dimension values */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? - ) = - dimensionalPriceConfiguration( - JsonField.ofNullable(dimensionalPriceConfiguration) - ) + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - /** - * Alias for calling [Builder.dimensionalPriceConfiguration] with - * `dimensionalPriceConfiguration.orElse(null)`. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.dimensionalPriceConfiguration] with a - * well-typed [NewDimensionalPriceConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Alias for calling [Builder.externalPriceId] with - * `externalPriceId.orElse(null)`. - */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.getOrNull()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.externalPriceId] to an arbitrary JSON value. - * - * You should usually call [Builder.externalPriceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + private var validated: Boolean = false /** - * Alias for [Builder.fixedPriceQuantity]. + * Validates that the types of all values in this object match their expected + * types recursively. * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * Alias for calling [Builder.fixedPriceQuantity] with - * `fixedPriceQuantity.orElse(null)`. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - - /** - * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. * - * You should usually call [Builder.fixedPriceQuantity] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + validated = true + } - /** - * Alias for calling [Builder.invoiceGroupingKey] with - * `invoiceGroupingKey.orElse(null)`. - */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } /** - * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.invoiceGroupingKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * Used for best match union deserialization. */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + additionalProperties == other.additionalProperties } - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: NewBillingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /** - * Alias for calling [Builder.invoicingCycleConfiguration] with - * `invoicingCycleConfiguration.orElse(null)`. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.invoicingCycleConfiguration] with a - * well-typed [NewBillingCycleConfiguration] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + return other is TieredWithProration && + cadence == other.cadence && + itemId == other.itemId && + modelType == other.modelType && + name == other.name && + tieredWithProrationConfig == other.tieredWithProrationConfig && + billableMetricId == other.billableMetricId && + billedInAdvance == other.billedInAdvance && + billingCycleConfiguration == other.billingCycleConfiguration && + conversionRate == other.conversionRate && + conversionRateConfig == other.conversionRateConfig && + currency == other.currency && + dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && + externalPriceId == other.externalPriceId && + fixedPriceQuantity == other.fixedPriceQuantity && + invoiceGroupingKey == other.invoiceGroupingKey && + invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && + metadata == other.metadata && + referenceId == other.referenceId && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + private val hashCode: Int by lazy { + Objects.hash( + cadence, + itemId, + modelType, + name, + tieredWithProrationConfig, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties, + ) + } - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: String?) = - referenceId(JsonField.ofNullable(referenceId)) + override fun hashCode(): Int = hashCode - /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.getOrNull()) + override fun toString() = + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.referenceId] to an arbitrary JSON value. - * - * You should usually call [Builder.referenceId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun referenceId(referenceId: JsonField) = apply { - this.referenceId = referenceId - } + class GroupedWithMinMaxThresholds + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cadence: JsonField, + private val groupedWithMinMaxThresholdsConfig: + JsonField, + private val itemId: JsonField, + private val modelType: JsonValue, + private val name: JsonField, + private val billableMetricId: JsonField, + private val billedInAdvance: JsonField, + private val billingCycleConfiguration: JsonField, + private val conversionRate: JsonField, + private val conversionRateConfig: JsonField, + private val currency: JsonField, + private val dimensionalPriceConfiguration: + JsonField, + private val externalPriceId: JsonField, + private val fixedPriceQuantity: JsonField, + private val invoiceGroupingKey: JsonField, + private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, + private val metadata: JsonField, + private val referenceId: JsonField, + private val additionalProperties: MutableMap, + ) { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + groupedWithMinMaxThresholdsConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + modelType: JsonValue = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate_config") + @ExcludeMissing + conversionRateConfig: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + referenceId: JsonField = JsonMissing.of(), + ) : this( + cadence, + groupedWithMinMaxThresholdsConfig, + itemId, + modelType, + name, + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + mutableMapOf(), + ) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * The cadence to bill for this price on. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cadence(): Cadence = cadence.getRequired("cadence") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Configuration for grouped_with_min_max_thresholds pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholdsConfig.getRequired( + "grouped_with_min_max_thresholds_config" + ) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * The id of the item the price will be associated with. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun itemId(): String = itemId.getRequired("item_id") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The pricing model type + * + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType - /** - * Returns an immutable instance of [BulkWithFilters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .bulkWithFiltersConfig() - * .cadence() - * .itemId() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFilters = - BulkWithFilters( - checkRequired("bulkWithFiltersConfig", bulkWithFiltersConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - modelType, - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - conversionRateConfig, - currency, - dimensionalPriceConfiguration, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toMutableMap(), - ) - } + /** + * The name of the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") - private var validated: Boolean = false + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billableMetricId(): Optional = + billableMetricId.getOptional("billable_metric_id") - fun validate(): BulkWithFilters = apply { - if (validated) { - return@apply - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billedInAdvance(): Optional = + billedInAdvance.getOptional("billed_in_advance") - bulkWithFiltersConfig().validate() - cadence().validate() - itemId() - _modelType().let { - if (it != JsonValue.from("bulk_with_filters")) { - throw OrbInvalidDataException("'modelType' is invalid, received $it") - } - } - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - conversionRateConfig().ifPresent { it.validate() } - currency() - dimensionalPriceConfiguration().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun billingCycleConfiguration(): Optional = + billingCycleConfiguration.getOptional("billing_cycle_configuration") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * The per unit conversion rate of the price currency to the invoicing currency. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversionRate(): Optional = + conversionRate.getOptional("conversion_rate") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * The configuration for the rate of the price currency to the invoicing currency. * - * Used for best match union deserialization. + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JvmSynthetic - internal fun validity(): Int = - (bulkWithFiltersConfig.asKnown().getOrNull()?.validity() ?: 0) + - (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { if (it == JsonValue.from("bulk_with_filters")) 1 else 0 } + - (if (name.asKnown().isPresent) 1 else 0) + - (if (billableMetricId.asKnown().isPresent) 1 else 0) + - (if (billedInAdvance.asKnown().isPresent) 1 else 0) + - (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (conversionRate.asKnown().isPresent) 1 else 0) + - (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (if (externalPriceId.asKnown().isPresent) 1 else 0) + - (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + - (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + - (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (referenceId.asKnown().isPresent) 1 else 0) + fun conversionRateConfig(): Optional = + conversionRateConfig.getOptional("conversion_rate_config") - /** Configuration for bulk_with_filters pricing */ - class BulkWithFiltersConfig - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val filters: JsonField>, - private val tiers: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") - @JsonCreator - private constructor( - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("tiers") - @ExcludeMissing - tiers: JsonField> = JsonMissing.of(), - ) : this(filters, tiers, mutableMapOf()) + /** + * For dimensional price: specifies a price group and dimension values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dimensionalPriceConfiguration(): Optional = + dimensionalPriceConfiguration.getOptional("dimensional_price_configuration") - /** - * Property filters to apply (all must match) - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun filters(): List = filters.getRequired("filters") + /** + * An alias for the price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun externalPriceId(): Optional = + externalPriceId.getOptional("external_price_id") - /** - * Bulk tiers for rating based on total usage volume - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tiers(): List = tiers.getRequired("tiers") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fixedPriceQuantity(): Optional = + fixedPriceQuantity.getOptional("fixed_price_quantity") - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters + /** + * The property used to group this price on an invoice + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoiceGroupingKey(): Optional = + invoiceGroupingKey.getOptional("invoice_grouping_key") - /** - * Returns the raw JSON value of [tiers]. - * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invoicingCycleConfiguration(): Optional = + invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") - fun toBuilder() = Builder().from(this) + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceId(): Optional = referenceId.getOptional("reference_id") - companion object { + /** + * Returns the raw JSON value of [cadence]. + * + * Unlike [cadence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence - /** - * Returns a mutable builder for constructing an instance of - * [BulkWithFiltersConfig]. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * + * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("grouped_with_min_max_thresholds_config") + @ExcludeMissing + fun _groupedWithMinMaxThresholdsConfig(): + JsonField = groupedWithMinMaxThresholdsConfig - /** A builder for [BulkWithFiltersConfig]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [itemId]. + * + * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var filters: JsonField>? = null - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmSynthetic - internal fun from(bulkWithFiltersConfig: BulkWithFiltersConfig) = apply { - filters = bulkWithFiltersConfig.filters.map { it.toMutableList() } - tiers = bulkWithFiltersConfig.tiers.map { it.toMutableList() } - additionalProperties = - bulkWithFiltersConfig.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [billableMetricId]. + * + * Unlike [billableMetricId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** Property filters to apply (all must match) */ - fun filters(filters: List) = filters(JsonField.of(filters)) + /** + * Returns the raw JSON value of [billedInAdvance]. + * + * Unlike [billedInAdvance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [billingCycleConfiguration]. + * + * Unlike [billingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } + /** + * Returns the raw JSON value of [conversionRate]. + * + * Unlike [conversionRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + /** + * Returns the raw JSON value of [conversionRateConfig]. + * + * Unlike [conversionRateConfig], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversion_rate_config") + @ExcludeMissing + fun _conversionRateConfig(): JsonField = conversionRateConfig - /** - * Sets [Builder.tiers] to an arbitrary JSON value. - * - * You should usually call [Builder.tiers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - /** - * Adds a single [Tier] to [tiers]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } - } + /** + * Returns the raw JSON value of [dimensionalPriceConfiguration]. + * + * Unlike [dimensionalPriceConfiguration], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [externalPriceId]. + * + * Unlike [externalPriceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [fixedPriceQuantity]. + * + * Unlike [fixedPriceQuantity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * Returns the raw JSON value of [invoiceGroupingKey]. + * + * Unlike [invoiceGroupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns the raw JSON value of [invoicingCycleConfiguration]. + * + * Unlike [invoicingCycleConfiguration], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** - * Returns an immutable instance of [BulkWithFiltersConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .filters() - * .tiers() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkWithFiltersConfig = - BulkWithFiltersConfig( - checkRequired("filters", filters).map { it.toImmutable() }, - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [referenceId]. + * + * Unlike [referenceId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId - private var validated: Boolean = false + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun validate(): BulkWithFiltersConfig = apply { - if (validated) { - return@apply - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - filters().forEach { it.validate() } - tiers().forEach { it.validate() } - validated = true - } + fun toBuilder() = Builder().from(this) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + companion object { /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholds]. * - * Used for best match union deserialization. + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` */ - @JvmSynthetic - internal fun validity(): Int = - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single property filter */ - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val propertyKey: JsonField, - private val propertyValue: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("property_key") - @ExcludeMissing - propertyKey: JsonField = JsonMissing.of(), - @JsonProperty("property_value") - @ExcludeMissing - propertyValue: JsonField = JsonMissing.of(), - ) : this(propertyKey, propertyValue, mutableMapOf()) + @JvmStatic fun builder() = Builder() + } - /** - * Event property key to filter on - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyKey(): String = propertyKey.getRequired("property_key") + /** A builder for [GroupedWithMinMaxThresholds]. */ + class Builder internal constructor() { - /** - * Event property value to match - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun propertyValue(): String = propertyValue.getRequired("property_value") + private var cadence: JsonField? = null + private var groupedWithMinMaxThresholdsConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_min_max_thresholds") + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var conversionRateConfig: JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns the raw JSON value of [propertyKey]. - * - * Unlike [propertyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("property_key") - @ExcludeMissing - fun _propertyKey(): JsonField = propertyKey + @JvmSynthetic + internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = + apply { + cadence = groupedWithMinMaxThresholds.cadence + groupedWithMinMaxThresholdsConfig = + groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig + itemId = groupedWithMinMaxThresholds.itemId + modelType = groupedWithMinMaxThresholds.modelType + name = groupedWithMinMaxThresholds.name + billableMetricId = groupedWithMinMaxThresholds.billableMetricId + billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance + billingCycleConfiguration = + groupedWithMinMaxThresholds.billingCycleConfiguration + conversionRate = groupedWithMinMaxThresholds.conversionRate + conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig + currency = groupedWithMinMaxThresholds.currency + dimensionalPriceConfiguration = + groupedWithMinMaxThresholds.dimensionalPriceConfiguration + externalPriceId = groupedWithMinMaxThresholds.externalPriceId + fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity + invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMinMaxThresholds.invoicingCycleConfiguration + licenseTypeId = groupedWithMinMaxThresholds.licenseTypeId + metadata = groupedWithMinMaxThresholds.metadata + referenceId = groupedWithMinMaxThresholds.referenceId + additionalProperties = + groupedWithMinMaxThresholds.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [propertyValue]. - * - * Unlike [propertyValue], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("property_value") - @ExcludeMissing - fun _propertyValue(): JsonField = propertyValue + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.cadence] to an arbitrary JSON value. + * + * You should usually call [Builder.cadence] with a well-typed [Cadence] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** Configuration for grouped_with_min_max_thresholds pricing */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = + groupedWithMinMaxThresholdsConfig( + JsonField.of(groupedWithMinMaxThresholdsConfig) + ) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a + * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun groupedWithMinMaxThresholdsConfig( + groupedWithMinMaxThresholdsConfig: + JsonField + ) = apply { + this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig + } - companion object { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.itemId] to an arbitrary JSON value. + * + * You should usually call [Builder.itemId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** A builder for [Filter]. */ - class Builder internal constructor() { + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_min_max_thresholds") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } - private var propertyKey: JsonField? = null - private var propertyValue: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JvmSynthetic - internal fun from(filter: Filter) = apply { - propertyKey = filter.propertyKey - propertyValue = filter.propertyValue - additionalProperties = filter.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** Event property key to filter on */ - fun propertyKey(propertyKey: String) = - propertyKey(JsonField.of(propertyKey)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** - * Sets [Builder.propertyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyKey] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyKey(propertyKey: JsonField) = apply { - this.propertyKey = propertyKey - } + /** + * Alias for calling [Builder.billableMetricId] with + * `billableMetricId.orElse(null)`. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.getOrNull()) - /** Event property value to match */ - fun propertyValue(propertyValue: String) = - propertyValue(JsonField.of(propertyValue)) + /** + * Sets [Builder.billableMetricId] to an arbitrary JSON value. + * + * You should usually call [Builder.billableMetricId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * Sets [Builder.propertyValue] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyValue] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun propertyValue(propertyValue: JsonField) = apply { - this.propertyValue = propertyValue - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Alias for [Builder.billedInAdvance]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Alias for calling [Builder.billedInAdvance] with + * `billedInAdvance.orElse(null)`. + */ + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.getOrNull()) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.billedInAdvance] to an arbitrary JSON value. + * + * You should usually call [Builder.billedInAdvance] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfiguration? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Alias for calling [Builder.billingCycleConfiguration] with + * `billingCycleConfiguration.orElse(null)`. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.getOrNull()) - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .propertyKey() - * .propertyValue() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("propertyKey", propertyKey), - checkRequired("propertyValue", propertyValue), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.billingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.billingCycleConfiguration] with a well-typed + * [NewBillingCycleConfiguration] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun validate(): Filter = apply { - if (validated) { - return@apply - } + /** + * Alias for [Builder.conversionRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - propertyKey() - propertyValue() - validated = true - } + /** + * Alias for calling [Builder.conversionRate] with + * `conversionRate.orElse(null)`. + */ + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.conversionRate] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRate] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (propertyKey.asKnown().isPresent) 1 else 0) + - (if (propertyValue.asKnown().isPresent) 1 else 0) + /** + * The configuration for the rate of the price currency to the invoicing + * currency. + */ + fun conversionRateConfig(conversionRateConfig: ConversionRateConfig?) = + conversionRateConfig(JsonField.ofNullable(conversionRateConfig)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Alias for calling [Builder.conversionRateConfig] with + * `conversionRateConfig.orElse(null)`. + */ + fun conversionRateConfig(conversionRateConfig: Optional) = + conversionRateConfig(conversionRateConfig.getOrNull()) - return other is Filter && - propertyKey == other.propertyKey && - propertyValue == other.propertyValue && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.conversionRateConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.conversionRateConfig] with a well-typed + * [ConversionRateConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun conversionRateConfig( + conversionRateConfig: JsonField + ) = apply { this.conversionRateConfig = conversionRateConfig } - private val hashCode: Int by lazy { - Objects.hash(propertyKey, propertyValue, additionalProperties) - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofUnit(unit)`. + */ + fun conversionRateConfig(unit: UnitConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofUnit(unit)) - override fun hashCode(): Int = hashCode + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * UnitConversionRateConfig.builder() + * .conversionRateType(UnitConversionRateConfig.ConversionRateType.UNIT) + * .unitConfig(unitConfig) + * .build() + * ``` + */ + fun unitConversionRateConfig(unitConfig: ConversionRateUnitConfig) = + conversionRateConfig( + UnitConversionRateConfig.builder() + .conversionRateType( + UnitConversionRateConfig.ConversionRateType.UNIT + ) + .unitConfig(unitConfig) + .build() + ) - override fun toString() = - "Filter{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" - } + /** + * Alias for calling [conversionRateConfig] with + * `ConversionRateConfig.ofTiered(tiered)`. + */ + fun conversionRateConfig(tiered: TieredConversionRateConfig) = + conversionRateConfig(ConversionRateConfig.ofTiered(tiered)) - /** Configuration for a single bulk pricing tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val unitAmount: JsonField, - private val tierLowerBound: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Alias for calling [conversionRateConfig] with the following: + * ```java + * TieredConversionRateConfig.builder() + * .conversionRateType(TieredConversionRateConfig.ConversionRateType.TIERED) + * .tieredConfig(tieredConfig) + * .build() + * ``` + */ + fun tieredConversionRateConfig(tieredConfig: ConversionRateTieredConfig) = + conversionRateConfig( + TieredConversionRateConfig.builder() + .conversionRateType( + TieredConversionRateConfig.ConversionRateType.TIERED + ) + .tieredConfig(tieredConfig) + .build() + ) - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - ) : this(unitAmount, tierLowerBound, mutableMapOf()) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) - /** - * The lower bound for this tier - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tierLowerBound(): Optional = - tierLowerBound.getOptional("tier_lower_bound") + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + /** For dimensional price: specifies a price group and dimension values */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: NewDimensionalPriceConfiguration? + ) = + dimensionalPriceConfiguration( + JsonField.ofNullable(dimensionalPriceConfiguration) + ) - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound + /** + * Alias for calling [Builder.dimensionalPriceConfiguration] with + * `dimensionalPriceConfiguration.orElse(null)`. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.getOrNull()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.dimensionalPriceConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionalPriceConfiguration] with a + * well-typed [NewDimensionalPriceConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun toBuilder() = Builder().from(this) + /** + * Alias for calling [Builder.externalPriceId] with + * `externalPriceId.orElse(null)`. + */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) - companion object { + /** + * Sets [Builder.externalPriceId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalPriceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** A builder for [Tier]. */ - class Builder internal constructor() { + /** + * Alias for [Builder.fixedPriceQuantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - private var unitAmount: JsonField? = null - private var tierLowerBound: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Alias for calling [Builder.fixedPriceQuantity] with + * `fixedPriceQuantity.orElse(null)`. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.getOrNull()) - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - tierLowerBound = tier.tierLowerBound - additionalProperties = tier.additionalProperties.toMutableMap() - } + /** + * Sets [Builder.fixedPriceQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.fixedPriceQuantity] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + /** + * Alias for calling [Builder.invoiceGroupingKey] with + * `invoiceGroupingKey.orElse(null)`. + */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.getOrNull()) - /** The lower bound for this tier */ - fun tierLowerBound(tierLowerBound: String?) = - tierLowerBound(JsonField.ofNullable(tierLowerBound)) + /** + * Sets [Builder.invoiceGroupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceGroupingKey] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * Alias for calling [Builder.tierLowerBound] with - * `tierLowerBound.orElse(null)`. - */ - fun tierLowerBound(tierLowerBound: Optional) = - tierLowerBound(tierLowerBound.getOrNull()) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfiguration? + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } + /** + * Alias for calling [Builder.invoicingCycleConfiguration] with + * `invoicingCycleConfiguration.orElse(null)`. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.getOrNull()) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sets [Builder.invoicingCycleConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.invoicingCycleConfiguration] with a + * well-typed [NewBillingCycleConfiguration] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - tierLowerBound, - additionalProperties.toMutableMap(), - ) - } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - private var validated: Boolean = false + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun validate(): Tier = apply { - if (validated) { - return@apply - } + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) - unitAmount() - tierLowerBound() - validated = true - } + /** Alias for calling [Builder.referenceId] with `referenceId.orElse(null)`. */ + fun referenceId(referenceId: Optional) = + referenceId(referenceId.getOrNull()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } + /** + * Sets [Builder.referenceId] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (unitAmount.asKnown().isPresent) 1 else 0) + - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return other is Tier && - unitAmount == other.unitAmount && - tierLowerBound == other.tierLowerBound && - additionalProperties == other.additionalProperties + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - private val hashCode: Int by lazy { - Objects.hash(unitAmount, tierLowerBound, additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Tier{unitAmount=$unitAmount, tierLowerBound=$tierLowerBound, additionalProperties=$additionalProperties}" + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMinMaxThresholdsConfig() + * .itemId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholds = + GroupedWithMinMaxThresholds( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMinMaxThresholdsConfig", + groupedWithMinMaxThresholdsConfig, + ), + checkRequired("itemId", itemId), + modelType, + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + conversionRateConfig, + currency, + dimensionalPriceConfiguration, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + licenseTypeId, + metadata, + referenceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): GroupedWithMinMaxThresholds = apply { + if (validated) { + return@apply } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + cadence().validate() + groupedWithMinMaxThresholdsConfig().validate() + itemId() + _modelType().let { + if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") } - - return other is BulkWithFiltersConfig && - filters == other.filters && - tiers == other.tiers && - additionalProperties == other.additionalProperties } + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + conversionRateConfig().ifPresent { it.validate() } + currency() + dimensionalPriceConfiguration().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } - private val hashCode: Int by lazy { - Objects.hash(filters, tiers, additionalProperties) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false } - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithFiltersConfig{filters=$filters, tiers=$tiers, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (itemId.asKnown().isPresent) 1 else 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + } + + (if (name.asKnown().isPresent) 1 else 0) + + (if (billableMetricId.asKnown().isPresent) 1 else 0) + + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (conversionRate.asKnown().isPresent) 1 else 0) + + (conversionRateConfig.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (dimensionalPriceConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalPriceId.asKnown().isPresent) 1 else 0) + + (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (referenceId.asKnown().isPresent) 1 else 0) /** The cadence to bill for this price on. */ class Cadence @@ -22243,6 +36933,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -22282,6 +36982,342 @@ private constructor( override fun toString() = value.toString() } + /** Configuration for grouped_with_min_max_thresholds pricing */ + class GroupedWithMinMaxThresholdsConfig + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val groupingKey: JsonField, + private val maximumCharge: JsonField, + private val minimumCharge: JsonField, + private val perUnitRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("maximum_charge") + @ExcludeMissing + maximumCharge: JsonField = JsonMissing.of(), + @JsonProperty("minimum_charge") + @ExcludeMissing + minimumCharge: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_rate") + @ExcludeMissing + perUnitRate: JsonField = JsonMissing.of(), + ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + + /** + * The event property used to group before applying thresholds + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The maximum amount to charge each group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + + /** + * The minimum amount to charge each group, regardless of usage + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + + /** + * The base price charged per group + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [maximumCharge]. + * + * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_charge") + @ExcludeMissing + fun _maximumCharge(): JsonField = maximumCharge + + /** + * Returns the raw JSON value of [minimumCharge]. + * + * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minimum_charge") + @ExcludeMissing + fun _minimumCharge(): JsonField = minimumCharge + + /** + * Returns the raw JSON value of [perUnitRate]. + * + * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("per_unit_rate") + @ExcludeMissing + fun _perUnitRate(): JsonField = perUnitRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMinMaxThresholdsConfig]. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + class Builder internal constructor() { + + private var groupingKey: JsonField? = null + private var maximumCharge: JsonField? = null + private var minimumCharge: JsonField? = null + private var perUnitRate: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig + ) = apply { + groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey + maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge + minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge + perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate + additionalProperties = + groupedWithMinMaxThresholdsConfig.additionalProperties + .toMutableMap() + } + + /** The event property used to group before applying thresholds */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey + } + + /** The maximum amount to charge each group */ + fun maximumCharge(maximumCharge: String) = + maximumCharge(JsonField.of(maximumCharge)) + + /** + * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun maximumCharge(maximumCharge: JsonField) = apply { + this.maximumCharge = maximumCharge + } + + /** The minimum amount to charge each group, regardless of usage */ + fun minimumCharge(minimumCharge: String) = + minimumCharge(JsonField.of(minimumCharge)) + + /** + * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumCharge] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun minimumCharge(minimumCharge: JsonField) = apply { + this.minimumCharge = minimumCharge + } + + /** The base price charged per group */ + fun perUnitRate(perUnitRate: String) = + perUnitRate(JsonField.of(perUnitRate)) + + /** + * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.perUnitRate] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun perUnitRate(perUnitRate: JsonField) = apply { + this.perUnitRate = perUnitRate + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupingKey() + * .maximumCharge() + * .minimumCharge() + * .perUnitRate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GroupedWithMinMaxThresholdsConfig = + GroupedWithMinMaxThresholdsConfig( + checkRequired("groupingKey", groupingKey), + checkRequired("maximumCharge", maximumCharge), + checkRequired("minimumCharge", minimumCharge), + checkRequired("perUnitRate", perUnitRate), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): GroupedWithMinMaxThresholdsConfig = apply { + if (validated) { + return@apply + } + + groupingKey() + maximumCharge() + minimumCharge() + perUnitRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (maximumCharge.asKnown().isPresent) 1 else 0) + + (if (minimumCharge.asKnown().isPresent) 1 else 0) + + (if (perUnitRate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GroupedWithMinMaxThresholdsConfig && + groupingKey == other.groupingKey && + maximumCharge == other.maximumCharge && + minimumCharge == other.minimumCharge && + perUnitRate == other.perUnitRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + groupingKey, + maximumCharge, + minimumCharge, + perUnitRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -22349,6 +37385,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -22398,9 +37444,10 @@ private constructor( return true } - return other is BulkWithFilters && - bulkWithFiltersConfig == other.bulkWithFiltersConfig && + return other is GroupedWithMinMaxThresholds && cadence == other.cadence && + groupedWithMinMaxThresholdsConfig == + other.groupedWithMinMaxThresholdsConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -22415,6 +37462,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -22422,8 +37470,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - bulkWithFiltersConfig, cadence, + groupedWithMinMaxThresholdsConfig, itemId, modelType, name, @@ -22438,6 +37486,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -22447,17 +37496,18 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithFilters{bulkWithFiltersConfig=$bulkWithFiltersConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class TieredWithProration + class CumulativeGroupedAllocation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, + private val cumulativeGroupedAllocationConfig: + JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, - private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, private val billingCycleConfiguration: JsonField, @@ -22470,6 +37520,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -22480,6 +37531,11 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + cumulativeGroupedAllocationConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), @@ -22489,10 +37545,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing billableMetricId: JsonField = JsonMissing.of(), @@ -22529,6 +37581,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -22537,10 +37592,10 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -22552,6 +37607,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -22566,6 +37622,18 @@ private constructor( */ fun cadence(): Cadence = cadence.getRequired("cadence") + /** + * Configuration for cumulative_grouped_allocation pricing + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = + cumulativeGroupedAllocationConfig.getRequired( + "cumulative_grouped_allocation_config" + ) + /** * The id of the item the price will be associated with. * @@ -22580,7 +37648,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -22597,16 +37665,6 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** - * Configuration for tiered_with_proration pricing - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -22711,6 +37769,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -22740,6 +37806,17 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence + /** + * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. + * + * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cumulative_grouped_allocation_config") + @ExcludeMissing + fun _cumulativeGroupedAllocationConfig(): + JsonField = cumulativeGroupedAllocationConfig + /** * Returns the raw JSON value of [itemId]. * @@ -22756,17 +37833,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [tieredWithProrationConfig]. - * - * Unlike [tieredWithProrationConfig], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * Returns the raw JSON value of [billableMetricId]. * @@ -22880,6 +37946,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -22916,28 +37992,30 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProration]. + * [CumulativeGroupedAllocation]. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProration]. */ + /** A builder for [CumulativeGroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null + private var cumulativeGroupedAllocationConfig: + JsonField? = + null private var itemId: JsonField? = null - private var modelType: JsonValue = JsonValue.from("tiered_with_proration") + private var modelType: JsonValue = + JsonValue.from("cumulative_grouped_allocation") private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() private var billingCycleConfiguration: JsonField = @@ -22955,35 +38033,40 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProration: TieredWithProration) = apply { - cadence = tieredWithProration.cadence - itemId = tieredWithProration.itemId - modelType = tieredWithProration.modelType - name = tieredWithProration.name - tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig - billableMetricId = tieredWithProration.billableMetricId - billedInAdvance = tieredWithProration.billedInAdvance - billingCycleConfiguration = tieredWithProration.billingCycleConfiguration - conversionRate = tieredWithProration.conversionRate - conversionRateConfig = tieredWithProration.conversionRateConfig - currency = tieredWithProration.currency - dimensionalPriceConfiguration = - tieredWithProration.dimensionalPriceConfiguration - externalPriceId = tieredWithProration.externalPriceId - fixedPriceQuantity = tieredWithProration.fixedPriceQuantity - invoiceGroupingKey = tieredWithProration.invoiceGroupingKey - invoicingCycleConfiguration = - tieredWithProration.invoicingCycleConfiguration - metadata = tieredWithProration.metadata - referenceId = tieredWithProration.referenceId - additionalProperties = - tieredWithProration.additionalProperties.toMutableMap() - } + internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = + apply { + cadence = cumulativeGroupedAllocation.cadence + cumulativeGroupedAllocationConfig = + cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig + itemId = cumulativeGroupedAllocation.itemId + modelType = cumulativeGroupedAllocation.modelType + name = cumulativeGroupedAllocation.name + billableMetricId = cumulativeGroupedAllocation.billableMetricId + billedInAdvance = cumulativeGroupedAllocation.billedInAdvance + billingCycleConfiguration = + cumulativeGroupedAllocation.billingCycleConfiguration + conversionRate = cumulativeGroupedAllocation.conversionRate + conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig + currency = cumulativeGroupedAllocation.currency + dimensionalPriceConfiguration = + cumulativeGroupedAllocation.dimensionalPriceConfiguration + externalPriceId = cumulativeGroupedAllocation.externalPriceId + fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = + cumulativeGroupedAllocation.invoicingCycleConfiguration + licenseTypeId = cumulativeGroupedAllocation.licenseTypeId + metadata = cumulativeGroupedAllocation.metadata + referenceId = cumulativeGroupedAllocation.referenceId + additionalProperties = + cumulativeGroupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -22997,6 +38080,29 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** Configuration for cumulative_grouped_allocation pricing */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = + cumulativeGroupedAllocationConfig( + JsonField.of(cumulativeGroupedAllocationConfig) + ) + + /** + * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a + * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cumulativeGroupedAllocationConfig( + cumulativeGroupedAllocationConfig: + JsonField + ) = apply { + this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -23015,7 +38121,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("tiered_with_proration") + * JsonValue.from("cumulative_grouped_allocation") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -23035,22 +38141,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Configuration for tiered_with_proration pricing */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - /** - * Sets [Builder.tieredWithProrationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.tieredWithProrationConfig] with a well-typed - * [TieredWithProrationConfig] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -23399,6 +38489,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -23463,27 +38574,30 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProration]. + * Returns an immutable instance of [CumulativeGroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() + * .cumulativeGroupedAllocationConfig() * .itemId() * .name() - * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProration = - TieredWithProration( + fun build(): CumulativeGroupedAllocation = + CumulativeGroupedAllocation( checkRequired("cadence", cadence), + checkRequired( + "cumulativeGroupedAllocationConfig", + cumulativeGroupedAllocationConfig, + ), checkRequired("itemId", itemId), modelType, checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -23495,6 +38609,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -23503,20 +38618,30 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProration = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CumulativeGroupedAllocation = apply { if (validated) { return@apply } cadence().validate() + cumulativeGroupedAllocationConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("tiered_with_proration")) { + if (it != JsonValue.from("cumulative_grouped_allocation")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -23528,6 +38653,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -23550,12 +38676,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + + (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("tiered_with_proration")) 1 else 0 + if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + - (tieredWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + (billingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + @@ -23567,6 +38693,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -23690,6 +38817,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -23729,40 +38866,115 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for tiered_with_proration pricing */ - class TieredWithProrationConfig + /** Configuration for cumulative_grouped_allocation pricing */ + class CumulativeGroupedAllocationConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tiers: JsonField>, + private val cumulativeAllocation: JsonField, + private val groupAllocation: JsonField, + private val groupingKey: JsonField, + private val unitAmount: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tiers") + @JsonProperty("cumulative_allocation") @ExcludeMissing - tiers: JsonField> = JsonMissing.of() - ) : this(tiers, mutableMapOf()) + cumulativeAllocation: JsonField = JsonMissing.of(), + @JsonProperty("group_allocation") + @ExcludeMissing + groupAllocation: JsonField = JsonMissing.of(), + @JsonProperty("grouping_key") + @ExcludeMissing + groupingKey: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + mutableMapOf(), + ) /** - * Tiers for rating based on total usage quantities into the specified tier with - * proration + * The overall allocation across all groups * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun tiers(): List = tiers.getRequired("tiers") + fun cumulativeAllocation(): String = + cumulativeAllocation.getRequired("cumulative_allocation") /** - * Returns the raw JSON value of [tiers]. + * The allocation per individual group * - * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - @JsonProperty("tiers") + fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + + /** + * The event property used to group usage before applying allocations + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun groupingKey(): String = groupingKey.getRequired("grouping_key") + + /** + * The amount to charge for each unit outside of the allocation + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [cumulativeAllocation]. + * + * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cumulative_allocation") @ExcludeMissing - fun _tiers(): JsonField> = tiers + fun _cumulativeAllocation(): JsonField = cumulativeAllocation + + /** + * Returns the raw JSON value of [groupAllocation]. + * + * Unlike [groupAllocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("group_allocation") + @ExcludeMissing + fun _groupAllocation(): JsonField = groupAllocation + + /** + * Returns the raw JSON value of [groupingKey]. + * + * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("grouping_key") + @ExcludeMissing + fun _groupingKey(): JsonField = groupingKey + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -23780,59 +38992,100 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredWithProrationConfig]. + * [CumulativeGroupedAllocationConfig]. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationConfig]. */ + /** A builder for [CumulativeGroupedAllocationConfig]. */ class Builder internal constructor() { - private var tiers: JsonField>? = null + private var cumulativeAllocation: JsonField? = null + private var groupAllocation: JsonField? = null + private var groupingKey: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - tiers = tieredWithProrationConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + internal fun from( + cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig + ) = apply { + cumulativeAllocation = + cumulativeGroupedAllocationConfig.cumulativeAllocation + groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation + groupingKey = cumulativeGroupedAllocationConfig.groupingKey + unitAmount = cumulativeGroupedAllocationConfig.unitAmount + additionalProperties = + cumulativeGroupedAllocationConfig.additionalProperties + .toMutableMap() + } + + /** The overall allocation across all groups */ + fun cumulativeAllocation(cumulativeAllocation: String) = + cumulativeAllocation(JsonField.of(cumulativeAllocation)) /** - * Tiers for rating based on total usage quantities into the specified tier - * with proration + * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.cumulativeAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { + this.cumulativeAllocation = cumulativeAllocation + } + + /** The allocation per individual group */ + fun groupAllocation(groupAllocation: String) = + groupAllocation(JsonField.of(groupAllocation)) /** - * Sets [Builder.tiers] to an arbitrary JSON value. + * Sets [Builder.groupAllocation] to an arbitrary JSON value. * - * You should usually call [Builder.tiers] with a well-typed `List` + * You should usually call [Builder.groupAllocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun groupAllocation(groupAllocation: JsonField) = apply { + this.groupAllocation = groupAllocation + } + + /** The event property used to group usage before applying allocations */ + fun groupingKey(groupingKey: String) = + groupingKey(JsonField.of(groupingKey)) + + /** + * Sets [Builder.groupingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.groupingKey] with a well-typed [String] * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } + fun groupingKey(groupingKey: JsonField) = apply { + this.groupingKey = groupingKey } + /** The amount to charge for each unit outside of the allocation */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + /** - * Adds a single [Tier] to [tiers]. + * Sets [Builder.unitAmount] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a - * non-list. + * You should usually call [Builder.unitAmount] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).also { - checkKnown("tiers", it).add(tier) - } + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } fun additionalProperties(additionalProperties: Map) = @@ -23858,32 +39111,51 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationConfig]. + * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tiers() + * .cumulativeAllocation() + * .groupAllocation() + * .groupingKey() + * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, + fun build(): CumulativeGroupedAllocationConfig = + CumulativeGroupedAllocationConfig( + checkRequired("cumulativeAllocation", cumulativeAllocation), + checkRequired("groupAllocation", groupAllocation), + checkRequired("groupingKey", groupingKey), + checkRequired("unitAmount", unitAmount), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TieredWithProrationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): CumulativeGroupedAllocationConfig = apply { if (validated) { return@apply } - tiers().forEach { it.validate() } + cumulativeAllocation() + groupAllocation() + groupingKey() + unitAmount() validated = true } @@ -23903,249 +39175,38 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Configuration for a single tiered with proration tier */ - class Tier - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tierLowerBound: JsonField, - private val unitAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tier_lower_bound") - @ExcludeMissing - tierLowerBound: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - unitAmount: JsonField = JsonMissing.of(), - ) : this(tierLowerBound, unitAmount, mutableMapOf()) - - /** - * Inclusive tier starting value - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun tierLowerBound(): String = - tierLowerBound.getRequired("tier_lower_bound") - - /** - * Amount per unit - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with - * an unexpected value). - */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Returns the raw JSON value of [tierLowerBound]. - * - * Unlike [tierLowerBound], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("tier_lower_bound") - @ExcludeMissing - fun _tierLowerBound(): JsonField = tierLowerBound - - /** - * Returns the raw JSON value of [unitAmount]. - * - * Unlike [unitAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tier]. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var tierLowerBound: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - tierLowerBound = tier.tierLowerBound - unitAmount = tier.unitAmount - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun tierLowerBound(tierLowerBound: String) = - tierLowerBound(JsonField.of(tierLowerBound)) - - /** - * Sets [Builder.tierLowerBound] to an arbitrary JSON value. - * - * You should usually call [Builder.tierLowerBound] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun tierLowerBound(tierLowerBound: JsonField) = apply { - this.tierLowerBound = tierLowerBound - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** - * Sets [Builder.unitAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.unitAmount] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tier]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .tierLowerBound() - * .unitAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tier = - Tier( - checkRequired("tierLowerBound", tierLowerBound), - checkRequired("unitAmount", unitAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - tierLowerBound() - unitAmount() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (tierLowerBound.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tier && - tierLowerBound == other.tierLowerBound && - unitAmount == other.unitAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tierLowerBound, unitAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{tierLowerBound=$tierLowerBound, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } + (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + + (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (groupingKey.asKnown().isPresent) 1 else 0) + + (if (unitAmount.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TieredWithProrationConfig && - tiers == other.tiers && + return other is CumulativeGroupedAllocationConfig && + cumulativeAllocation == other.cumulativeAllocation && + groupAllocation == other.groupAllocation && + groupingKey == other.groupingKey && + unitAmount == other.unitAmount && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + cumulativeAllocation, + groupAllocation, + groupingKey, + unitAmount, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationConfig{tiers=$tiers, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } /** @@ -24215,6 +39276,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -24264,12 +39335,13 @@ private constructor( return true } - return other is TieredWithProration && + return other is CumulativeGroupedAllocation && cadence == other.cadence && + cumulativeGroupedAllocationConfig == + other.cumulativeGroupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && - tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && @@ -24281,6 +39353,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -24289,10 +39362,10 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, + cumulativeGroupedAllocationConfig, itemId, modelType, name, - tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -24304,6 +39377,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -24313,15 +39387,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class GroupedWithMinMaxThresholds + class DailyCreditAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val groupedWithMinMaxThresholdsConfig: - JsonField, + private val dailyCreditAllowanceConfig: JsonField, private val itemId: JsonField, private val modelType: JsonValue, private val name: JsonField, @@ -24337,6 +39410,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -24347,10 +39421,9 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - groupedWithMinMaxThresholdsConfig: - JsonField = + dailyCreditAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -24397,6 +39470,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -24405,7 +39481,7 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -24420,6 +39496,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -24435,16 +39512,14 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for grouped_with_min_max_thresholds pricing + * Configuration for daily_credit_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun groupedWithMinMaxThresholdsConfig(): GroupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholdsConfig.getRequired( - "grouped_with_min_max_thresholds_config" - ) + fun dailyCreditAllowanceConfig(): DailyCreditAllowanceConfig = + dailyCreditAllowanceConfig.getRequired("daily_credit_allowance_config") /** * The id of the item the price will be associated with. @@ -24460,7 +39535,7 @@ private constructor( * * Expected to always return the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -24581,6 +39656,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -24611,15 +39694,15 @@ private constructor( fun _cadence(): JsonField = cadence /** - * Returns the raw JSON value of [groupedWithMinMaxThresholdsConfig]. + * Returns the raw JSON value of [dailyCreditAllowanceConfig]. * - * Unlike [groupedWithMinMaxThresholdsConfig], this method doesn't throw if the JSON - * field has an unexpected type. + * Unlike [dailyCreditAllowanceConfig], this method doesn't throw if the JSON field + * has an unexpected type. */ - @JsonProperty("grouped_with_min_max_thresholds_config") + @JsonProperty("daily_credit_allowance_config") @ExcludeMissing - fun _groupedWithMinMaxThresholdsConfig(): - JsonField = groupedWithMinMaxThresholdsConfig + fun _dailyCreditAllowanceConfig(): JsonField = + dailyCreditAllowanceConfig /** * Returns the raw JSON value of [itemId]. @@ -24750,6 +39833,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -24786,12 +39879,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholds]. + * [DailyCreditAllowance]. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` @@ -24799,16 +39892,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholds]. */ + /** A builder for [DailyCreditAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithMinMaxThresholdsConfig: - JsonField? = + private var dailyCreditAllowanceConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("grouped_with_min_max_thresholds") + private var modelType: JsonValue = JsonValue.from("daily_credit_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -24827,38 +39918,37 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedWithMinMaxThresholds: GroupedWithMinMaxThresholds) = - apply { - cadence = groupedWithMinMaxThresholds.cadence - groupedWithMinMaxThresholdsConfig = - groupedWithMinMaxThresholds.groupedWithMinMaxThresholdsConfig - itemId = groupedWithMinMaxThresholds.itemId - modelType = groupedWithMinMaxThresholds.modelType - name = groupedWithMinMaxThresholds.name - billableMetricId = groupedWithMinMaxThresholds.billableMetricId - billedInAdvance = groupedWithMinMaxThresholds.billedInAdvance - billingCycleConfiguration = - groupedWithMinMaxThresholds.billingCycleConfiguration - conversionRate = groupedWithMinMaxThresholds.conversionRate - conversionRateConfig = groupedWithMinMaxThresholds.conversionRateConfig - currency = groupedWithMinMaxThresholds.currency - dimensionalPriceConfiguration = - groupedWithMinMaxThresholds.dimensionalPriceConfiguration - externalPriceId = groupedWithMinMaxThresholds.externalPriceId - fixedPriceQuantity = groupedWithMinMaxThresholds.fixedPriceQuantity - invoiceGroupingKey = groupedWithMinMaxThresholds.invoiceGroupingKey - invoicingCycleConfiguration = - groupedWithMinMaxThresholds.invoicingCycleConfiguration - metadata = groupedWithMinMaxThresholds.metadata - referenceId = groupedWithMinMaxThresholds.referenceId - additionalProperties = - groupedWithMinMaxThresholds.additionalProperties.toMutableMap() - } + private var licenseTypeId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dailyCreditAllowance: DailyCreditAllowance) = apply { + cadence = dailyCreditAllowance.cadence + dailyCreditAllowanceConfig = dailyCreditAllowance.dailyCreditAllowanceConfig + itemId = dailyCreditAllowance.itemId + modelType = dailyCreditAllowance.modelType + name = dailyCreditAllowance.name + billableMetricId = dailyCreditAllowance.billableMetricId + billedInAdvance = dailyCreditAllowance.billedInAdvance + billingCycleConfiguration = dailyCreditAllowance.billingCycleConfiguration + conversionRate = dailyCreditAllowance.conversionRate + conversionRateConfig = dailyCreditAllowance.conversionRateConfig + currency = dailyCreditAllowance.currency + dimensionalPriceConfiguration = + dailyCreditAllowance.dimensionalPriceConfiguration + externalPriceId = dailyCreditAllowance.externalPriceId + fixedPriceQuantity = dailyCreditAllowance.fixedPriceQuantity + invoiceGroupingKey = dailyCreditAllowance.invoiceGroupingKey + invoicingCycleConfiguration = + dailyCreditAllowance.invoicingCycleConfiguration + licenseTypeId = dailyCreditAllowance.licenseTypeId + metadata = dailyCreditAllowance.metadata + referenceId = dailyCreditAllowance.referenceId + additionalProperties = + dailyCreditAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -24872,28 +39962,22 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for grouped_with_min_max_thresholds pricing */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = - groupedWithMinMaxThresholdsConfig( - JsonField.of(groupedWithMinMaxThresholdsConfig) - ) + /** Configuration for daily_credit_allowance pricing */ + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: DailyCreditAllowanceConfig + ) = dailyCreditAllowanceConfig(JsonField.of(dailyCreditAllowanceConfig)) /** - * Sets [Builder.groupedWithMinMaxThresholdsConfig] to an arbitrary JSON value. + * Sets [Builder.dailyCreditAllowanceConfig] to an arbitrary JSON value. * - * You should usually call [Builder.groupedWithMinMaxThresholdsConfig] with a - * well-typed [GroupedWithMinMaxThresholdsConfig] value instead. This method is + * You should usually call [Builder.dailyCreditAllowanceConfig] with a + * well-typed [DailyCreditAllowanceConfig] value instead. This method is * primarily for setting the field to an undocumented or not yet supported * value. */ - fun groupedWithMinMaxThresholdsConfig( - groupedWithMinMaxThresholdsConfig: - JsonField - ) = apply { - this.groupedWithMinMaxThresholdsConfig = groupedWithMinMaxThresholdsConfig - } + fun dailyCreditAllowanceConfig( + dailyCreditAllowanceConfig: JsonField + ) = apply { this.dailyCreditAllowanceConfig = dailyCreditAllowanceConfig } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -24913,7 +39997,7 @@ private constructor( * It is usually unnecessary to call this method because the field defaults to * the following: * ```java - * JsonValue.from("grouped_with_min_max_thresholds") + * JsonValue.from("daily_credit_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -25281,6 +40365,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -25345,27 +40450,24 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholds]. + * Returns an immutable instance of [DailyCreditAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .groupedWithMinMaxThresholdsConfig() + * .dailyCreditAllowanceConfig() * .itemId() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholds = - GroupedWithMinMaxThresholds( + fun build(): DailyCreditAllowance = + DailyCreditAllowance( checkRequired("cadence", cadence), - checkRequired( - "groupedWithMinMaxThresholdsConfig", - groupedWithMinMaxThresholdsConfig, - ), + checkRequired("dailyCreditAllowanceConfig", dailyCreditAllowanceConfig), checkRequired("itemId", itemId), modelType, checkRequired("name", name), @@ -25380,6 +40482,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -25388,16 +40491,26 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholds = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): DailyCreditAllowance = apply { if (validated) { return@apply } cadence().validate() - groupedWithMinMaxThresholdsConfig().validate() + dailyCreditAllowanceConfig().validate() itemId() _modelType().let { - if (it != JsonValue.from("grouped_with_min_max_thresholds")) { + if (it != JsonValue.from("daily_credit_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -25413,6 +40526,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -25435,10 +40549,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (groupedWithMinMaxThresholdsConfig.asKnown().getOrNull()?.validity() ?: 0) + + (dailyCreditAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + modelType.let { - if (it == JsonValue.from("grouped_with_min_max_thresholds")) 1 else 0 + if (it == JsonValue.from("daily_credit_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -25452,6 +40566,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -25575,6 +40690,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -25614,108 +40739,144 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for grouped_with_min_max_thresholds pricing */ - class GroupedWithMinMaxThresholdsConfig + /** Configuration for daily_credit_allowance pricing */ + class DailyCreditAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val groupingKey: JsonField, - private val maximumCharge: JsonField, - private val minimumCharge: JsonField, - private val perUnitRate: JsonField, + private val dailyAllowance: JsonField, + private val defaultUnitAmount: JsonField, + private val dimensions: JsonField>, + private val eventDayProperty: JsonField, + private val matrixValues: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - groupingKey: JsonField = JsonMissing.of(), - @JsonProperty("maximum_charge") + dailyAllowance: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") @ExcludeMissing - maximumCharge: JsonField = JsonMissing.of(), - @JsonProperty("minimum_charge") + defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") @ExcludeMissing - minimumCharge: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_rate") + dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("event_day_property") @ExcludeMissing - perUnitRate: JsonField = JsonMissing.of(), - ) : this(groupingKey, maximumCharge, minimumCharge, perUnitRate, mutableMapOf()) + eventDayProperty: JsonField = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + matrixValues: JsonField> = JsonMissing.of(), + ) : this( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + mutableMapOf(), + ) /** - * The event property used to group before applying thresholds + * Credits granted per day. Lose-it-or-use-it; does not roll over. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupingKey(): String = groupingKey.getRequired("grouping_key") + fun dailyAllowance(): String = dailyAllowance.getRequired("daily_allowance") /** - * The maximum amount to charge each group + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun maximumCharge(): String = maximumCharge.getRequired("maximum_charge") + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") /** - * The minimum amount to charge each group, regardless of usage + * One or two event property values to evaluate matrix groups by * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun minimumCharge(): String = minimumCharge.getRequired("minimum_charge") + fun dimensions(): List = dimensions.getRequired("dimensions") /** - * The base price charged per group + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). The + * allowance resets per distinct value of this property. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun perUnitRate(): String = perUnitRate.getRequired("per_unit_rate") + fun eventDayProperty(): String = + eventDayProperty.getRequired("event_day_property") /** - * Returns the raw JSON value of [groupingKey]. + * Per-dimension credit rates * - * Unlike [groupingKey], this method doesn't throw if the JSON field has an + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** + * Returns the raw JSON value of [dailyAllowance]. + * + * Unlike [dailyAllowance], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("grouping_key") + @JsonProperty("daily_allowance") @ExcludeMissing - fun _groupingKey(): JsonField = groupingKey + fun _dailyAllowance(): JsonField = dailyAllowance /** - * Returns the raw JSON value of [maximumCharge]. + * Returns the raw JSON value of [defaultUnitAmount]. * - * Unlike [maximumCharge], this method doesn't throw if the JSON field has an + * Unlike [defaultUnitAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** + * Returns the raw JSON value of [dimensions]. + * + * Unlike [dimensions], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("maximum_charge") + @JsonProperty("dimensions") @ExcludeMissing - fun _maximumCharge(): JsonField = maximumCharge + fun _dimensions(): JsonField> = dimensions /** - * Returns the raw JSON value of [minimumCharge]. + * Returns the raw JSON value of [eventDayProperty]. * - * Unlike [minimumCharge], this method doesn't throw if the JSON field has an + * Unlike [eventDayProperty], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("minimum_charge") + @JsonProperty("event_day_property") @ExcludeMissing - fun _minimumCharge(): JsonField = minimumCharge + fun _eventDayProperty(): JsonField = eventDayProperty /** - * Returns the raw JSON value of [perUnitRate]. + * Returns the raw JSON value of [matrixValues]. * - * Unlike [perUnitRate], this method doesn't throw if the JSON field has an + * Unlike [matrixValues], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("per_unit_rate") + @JsonProperty("matrix_values") @ExcludeMissing - fun _perUnitRate(): JsonField = perUnitRate + fun _matrixValues(): JsonField> = matrixValues @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -25733,100 +40894,583 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMinMaxThresholdsConfig]. + * [DailyCreditAllowanceConfig]. * * The following fields are required: * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMinMaxThresholdsConfig]. */ + /** A builder for [DailyCreditAllowanceConfig]. */ class Builder internal constructor() { - private var groupingKey: JsonField? = null - private var maximumCharge: JsonField? = null - private var minimumCharge: JsonField? = null - private var perUnitRate: JsonField? = null + private var dailyAllowance: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var eventDayProperty: JsonField? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - groupedWithMinMaxThresholdsConfig: GroupedWithMinMaxThresholdsConfig - ) = apply { - groupingKey = groupedWithMinMaxThresholdsConfig.groupingKey - maximumCharge = groupedWithMinMaxThresholdsConfig.maximumCharge - minimumCharge = groupedWithMinMaxThresholdsConfig.minimumCharge - perUnitRate = groupedWithMinMaxThresholdsConfig.perUnitRate - additionalProperties = - groupedWithMinMaxThresholdsConfig.additionalProperties - .toMutableMap() - } + internal fun from(dailyCreditAllowanceConfig: DailyCreditAllowanceConfig) = + apply { + dailyAllowance = dailyCreditAllowanceConfig.dailyAllowance + defaultUnitAmount = dailyCreditAllowanceConfig.defaultUnitAmount + dimensions = + dailyCreditAllowanceConfig.dimensions.map { it.toMutableList() } + eventDayProperty = dailyCreditAllowanceConfig.eventDayProperty + matrixValues = + dailyCreditAllowanceConfig.matrixValues.map { + it.toMutableList() + } + additionalProperties = + dailyCreditAllowanceConfig.additionalProperties.toMutableMap() + } - /** The event property used to group before applying thresholds */ - fun groupingKey(groupingKey: String) = - groupingKey(JsonField.of(groupingKey)) + /** Credits granted per day. Lose-it-or-use-it; does not roll over. */ + fun dailyAllowance(dailyAllowance: String) = + dailyAllowance(JsonField.of(dailyAllowance)) /** - * Sets [Builder.groupingKey] to an arbitrary JSON value. + * Sets [Builder.dailyAllowance] to an arbitrary JSON value. * - * You should usually call [Builder.groupingKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.dailyAllowance] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun groupingKey(groupingKey: JsonField) = apply { - this.groupingKey = groupingKey + fun dailyAllowance(dailyAllowance: JsonField) = apply { + this.dailyAllowance = dailyAllowance } - /** The maximum amount to charge each group */ - fun maximumCharge(maximumCharge: String) = - maximumCharge(JsonField.of(maximumCharge)) + /** + * Default per-unit credit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** - * Sets [Builder.maximumCharge] to an arbitrary JSON value. + * Sets [Builder.defaultUnitAmount] to an arbitrary JSON value. * - * You should usually call [Builder.maximumCharge] with a well-typed + * You should usually call [Builder.defaultUnitAmount] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun maximumCharge(maximumCharge: JsonField) = apply { - this.maximumCharge = maximumCharge + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { + this.defaultUnitAmount = defaultUnitAmount } - /** The minimum amount to charge each group, regardless of usage */ - fun minimumCharge(minimumCharge: String) = - minimumCharge(JsonField.of(minimumCharge)) + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) /** - * Sets [Builder.minimumCharge] to an arbitrary JSON value. + * Sets [Builder.dimensions] to an arbitrary JSON value. * - * You should usually call [Builder.minimumCharge] with a well-typed + * You should usually call [Builder.dimensions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensions]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** + * Event property whose value identifies the day bucket the event belongs to + * (e.g. 'event_day' set to an ISO date string in the customer's timezone). + * The allowance resets per distinct value of this property. + */ + fun eventDayProperty(eventDayProperty: String) = + eventDayProperty(JsonField.of(eventDayProperty)) + + /** + * Sets [Builder.eventDayProperty] to an arbitrary JSON value. + * + * You should usually call [Builder.eventDayProperty] with a well-typed * [String] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ - fun minimumCharge(minimumCharge: JsonField) = apply { - this.minimumCharge = minimumCharge + fun eventDayProperty(eventDayProperty: JsonField) = apply { + this.eventDayProperty = eventDayProperty } - /** The base price charged per group */ - fun perUnitRate(perUnitRate: String) = - perUnitRate(JsonField.of(perUnitRate)) + /** Per-dimension credit rates */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) /** - * Sets [Builder.perUnitRate] to an arbitrary JSON value. + * Sets [Builder.matrixValues] to an arbitrary JSON value. * - * You should usually call [Builder.perUnitRate] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * You should usually call [Builder.matrixValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun perUnitRate(perUnitRate: JsonField) = apply { - this.perUnitRate = perUnitRate + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** + * Adds a single [MatrixValue] to [matrixValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).also { + checkKnown("matrixValues", it).add(matrixValue) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DailyCreditAllowanceConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dailyAllowance() + * .defaultUnitAmount() + * .dimensions() + * .eventDayProperty() + * .matrixValues() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DailyCreditAllowanceConfig = + DailyCreditAllowanceConfig( + checkRequired("dailyAllowance", dailyAllowance), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("eventDayProperty", eventDayProperty), + checkRequired("matrixValues", matrixValues).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): DailyCreditAllowanceConfig = apply { + if (validated) { + return@apply + } + + dailyAllowance() + defaultUnitAmount() + dimensions() + eventDayProperty() + matrixValues().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dailyAllowance.asKnown().isPresent) 1 else 0) + + (if (defaultUnitAmount.asKnown().isPresent) 1 else 0) + + (dimensions.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + + (if (eventDayProperty.asKnown().isPresent) 1 else 0) + + (matrixValues.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Per-dimension credit price for the daily credit allowance model. */ + class MatrixValue + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dimensionValues: JsonField>, + private val unitAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + unitAmount: JsonField = JsonMissing.of(), + ) : this(dimensionValues, unitAmount, mutableMapOf()) + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** + * Credits charged per unit of usage matching the specified dimension_values + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Returns the raw JSON value of [dimensionValues]. + * + * Unlike [dimensionValues], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** + * Returns the raw JSON value of [unitAmount]. + * + * Unlike [unitAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixValue]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValue]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValue: MatrixValue) = apply { + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValue.unitAmount + additionalProperties = + matrixValue.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this value by. For example, + * ["model"] could be used to apply a different credit rate to each AI + * model. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * Sets [Builder.dimensionValues] to an arbitrary JSON value. + * + * You should usually call [Builder.dimensionValues] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [dimensionValues]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** + * Credits charged per unit of usage matching the specified + * dimension_values + */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** + * Sets [Builder.unitAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.unitAmount] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MatrixValue]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MatrixValue = + MatrixValue( + checkRequired("dimensionValues", dimensionValues).map { + it.toImmutable() + }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their + * expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MatrixValue = apply { + if (validated) { + return@apply + } + + dimensionValues() + unitAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OrbInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (dimensionValues.asKnown().getOrNull()?.sumOf { + (if (it == null) 0 else 1).toInt() + } ?: 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MatrixValue && + dimensionValues == other.dimensionValues && + unitAmount == other.unitAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dimensionValues, unitAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DailyCreditAllowanceConfig && + dailyAllowance == other.dailyAllowance && + defaultUnitAmount == other.defaultUnitAmount && + dimensions == other.dimensions && + eventDayProperty == other.eventDayProperty && + matrixValues == other.matrixValues && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + dailyAllowance, + defaultUnitAmount, + dimensions, + eventDayProperty, + matrixValues, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DailyCreditAllowanceConfig{dailyAllowance=$dailyAllowance, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, eventDayProperty=$eventDayProperty, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = @@ -25852,161 +41496,25 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMinMaxThresholdsConfig]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .groupingKey() - * .maximumCharge() - * .minimumCharge() - * .perUnitRate() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMinMaxThresholdsConfig = - GroupedWithMinMaxThresholdsConfig( - checkRequired("groupingKey", groupingKey), - checkRequired("maximumCharge", maximumCharge), - checkRequired("minimumCharge", minimumCharge), - checkRequired("perUnitRate", perUnitRate), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): GroupedWithMinMaxThresholdsConfig = apply { - if (validated) { - return@apply - } - - groupingKey() - maximumCharge() - minimumCharge() - perUnitRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Validates that the types of all values in this object match their expected + * types recursively. * - * Used for best match union deserialization. + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. */ - @JvmSynthetic - internal fun validity(): Int = - (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (maximumCharge.asKnown().isPresent) 1 else 0) + - (if (minimumCharge.asKnown().isPresent) 1 else 0) + - (if (perUnitRate.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupedWithMinMaxThresholdsConfig && - groupingKey == other.groupingKey && - maximumCharge == other.maximumCharge && - minimumCharge == other.minimumCharge && - perUnitRate == other.perUnitRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - groupingKey, - maximumCharge, - minimumCharge, - perUnitRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMinMaxThresholdsConfig{groupingKey=$groupingKey, maximumCharge=$maximumCharge, minimumCharge=$minimumCharge, perUnitRate=$perUnitRate, additionalProperties=$additionalProperties}" - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - fun validate(): Metadata = apply { if (validated) { return@apply @@ -26056,10 +41564,9 @@ private constructor( return true } - return other is GroupedWithMinMaxThresholds && + return other is DailyCreditAllowance && cadence == other.cadence && - groupedWithMinMaxThresholdsConfig == - other.groupedWithMinMaxThresholdsConfig && + dailyCreditAllowanceConfig == other.dailyCreditAllowanceConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && @@ -26074,6 +41581,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -26082,7 +41590,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - groupedWithMinMaxThresholdsConfig, + dailyCreditAllowanceConfig, itemId, modelType, name, @@ -26097,6 +41605,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -26106,16 +41615,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMinMaxThresholds{cadence=$cadence, groupedWithMinMaxThresholdsConfig=$groupedWithMinMaxThresholdsConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "DailyCreditAllowance{cadence=$cadence, dailyCreditAllowanceConfig=$dailyCreditAllowanceConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class CumulativeGroupedAllocation + class MeteredAllowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val cadence: JsonField, - private val cumulativeGroupedAllocationConfig: - JsonField, private val itemId: JsonField, + private val meteredAllowanceConfig: JsonField, private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, @@ -26130,6 +41638,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -26140,14 +41649,12 @@ private constructor( @JsonProperty("cadence") @ExcludeMissing cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - cumulativeGroupedAllocationConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), + @JsonProperty("metered_allowance_config") + @ExcludeMissing + meteredAllowanceConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @@ -26190,6 +41697,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -26198,8 +41708,8 @@ private constructor( referenceId: JsonField = JsonMissing.of(), ) : this( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -26213,6 +41723,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -26228,32 +41739,30 @@ private constructor( fun cadence(): Cadence = cadence.getRequired("cadence") /** - * Configuration for cumulative_grouped_allocation pricing + * The id of the item the price will be associated with. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun cumulativeGroupedAllocationConfig(): CumulativeGroupedAllocationConfig = - cumulativeGroupedAllocationConfig.getRequired( - "cumulative_grouped_allocation_config" - ) + fun itemId(): String = itemId.getRequired("item_id") /** - * The id of the item the price will be associated with. + * Configuration for metered_allowance pricing * * @throws OrbInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun itemId(): String = itemId.getRequired("item_id") + fun meteredAllowanceConfig(): MeteredAllowanceConfig = + meteredAllowanceConfig.getRequired("metered_allowance_config") /** * The pricing model type * * Expected to always return the following: * ```java - * JsonValue.from("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * However, this method can be useful for debugging and logging (e.g. if the server @@ -26374,6 +41883,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -26403,17 +41920,6 @@ private constructor( @ExcludeMissing fun _cadence(): JsonField = cadence - /** - * Returns the raw JSON value of [cumulativeGroupedAllocationConfig]. - * - * Unlike [cumulativeGroupedAllocationConfig], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("cumulative_grouped_allocation_config") - @ExcludeMissing - fun _cumulativeGroupedAllocationConfig(): - JsonField = cumulativeGroupedAllocationConfig - /** * Returns the raw JSON value of [itemId]. * @@ -26422,6 +41928,17 @@ private constructor( */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * Returns the raw JSON value of [meteredAllowanceConfig]. + * + * Unlike [meteredAllowanceConfig], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("metered_allowance_config") + @ExcludeMissing + fun _meteredAllowanceConfig(): JsonField = + meteredAllowanceConfig + /** * Returns the raw JSON value of [name]. * @@ -26543,6 +42060,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -26578,30 +42105,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocation]. + * Returns a mutable builder for constructing an instance of [MeteredAllowance]. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocation]. */ + /** A builder for [MeteredAllowance]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedAllocationConfig: - JsonField? = - null private var itemId: JsonField? = null - private var modelType: JsonValue = - JsonValue.from("cumulative_grouped_allocation") + private var meteredAllowanceConfig: JsonField? = null + private var modelType: JsonValue = JsonValue.from("metered_allowance") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -26620,38 +42143,35 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedAllocation: CumulativeGroupedAllocation) = - apply { - cadence = cumulativeGroupedAllocation.cadence - cumulativeGroupedAllocationConfig = - cumulativeGroupedAllocation.cumulativeGroupedAllocationConfig - itemId = cumulativeGroupedAllocation.itemId - modelType = cumulativeGroupedAllocation.modelType - name = cumulativeGroupedAllocation.name - billableMetricId = cumulativeGroupedAllocation.billableMetricId - billedInAdvance = cumulativeGroupedAllocation.billedInAdvance - billingCycleConfiguration = - cumulativeGroupedAllocation.billingCycleConfiguration - conversionRate = cumulativeGroupedAllocation.conversionRate - conversionRateConfig = cumulativeGroupedAllocation.conversionRateConfig - currency = cumulativeGroupedAllocation.currency - dimensionalPriceConfiguration = - cumulativeGroupedAllocation.dimensionalPriceConfiguration - externalPriceId = cumulativeGroupedAllocation.externalPriceId - fixedPriceQuantity = cumulativeGroupedAllocation.fixedPriceQuantity - invoiceGroupingKey = cumulativeGroupedAllocation.invoiceGroupingKey - invoicingCycleConfiguration = - cumulativeGroupedAllocation.invoicingCycleConfiguration - metadata = cumulativeGroupedAllocation.metadata - referenceId = cumulativeGroupedAllocation.referenceId - additionalProperties = - cumulativeGroupedAllocation.additionalProperties.toMutableMap() - } + internal fun from(meteredAllowance: MeteredAllowance) = apply { + cadence = meteredAllowance.cadence + itemId = meteredAllowance.itemId + meteredAllowanceConfig = meteredAllowance.meteredAllowanceConfig + modelType = meteredAllowance.modelType + name = meteredAllowance.name + billableMetricId = meteredAllowance.billableMetricId + billedInAdvance = meteredAllowance.billedInAdvance + billingCycleConfiguration = meteredAllowance.billingCycleConfiguration + conversionRate = meteredAllowance.conversionRate + conversionRateConfig = meteredAllowance.conversionRateConfig + currency = meteredAllowance.currency + dimensionalPriceConfiguration = + meteredAllowance.dimensionalPriceConfiguration + externalPriceId = meteredAllowance.externalPriceId + fixedPriceQuantity = meteredAllowance.fixedPriceQuantity + invoiceGroupingKey = meteredAllowance.invoiceGroupingKey + invoicingCycleConfiguration = meteredAllowance.invoicingCycleConfiguration + licenseTypeId = meteredAllowance.licenseTypeId + metadata = meteredAllowance.metadata + referenceId = meteredAllowance.referenceId + additionalProperties = meteredAllowance.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -26665,29 +42185,6 @@ private constructor( */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Configuration for cumulative_grouped_allocation pricing */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = - cumulativeGroupedAllocationConfig( - JsonField.of(cumulativeGroupedAllocationConfig) - ) - - /** - * Sets [Builder.cumulativeGroupedAllocationConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.cumulativeGroupedAllocationConfig] with a - * well-typed [CumulativeGroupedAllocationConfig] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun cumulativeGroupedAllocationConfig( - cumulativeGroupedAllocationConfig: - JsonField - ) = apply { - this.cumulativeGroupedAllocationConfig = cumulativeGroupedAllocationConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -26700,13 +42197,28 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** Configuration for metered_allowance pricing */ + fun meteredAllowanceConfig(meteredAllowanceConfig: MeteredAllowanceConfig) = + meteredAllowanceConfig(JsonField.of(meteredAllowanceConfig)) + + /** + * Sets [Builder.meteredAllowanceConfig] to an arbitrary JSON value. + * + * You should usually call [Builder.meteredAllowanceConfig] with a well-typed + * [MeteredAllowanceConfig] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun meteredAllowanceConfig( + meteredAllowanceConfig: JsonField + ) = apply { this.meteredAllowanceConfig = meteredAllowanceConfig } + /** * 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("cumulative_grouped_allocation") + * JsonValue.from("metered_allowance") * ``` * * This method is primarily for setting the field to an undocumented or not yet @@ -27074,6 +42586,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -27138,28 +42671,25 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocation]. + * Returns an immutable instance of [MeteredAllowance]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .cadence() - * .cumulativeGroupedAllocationConfig() * .itemId() + * .meteredAllowanceConfig() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocation = - CumulativeGroupedAllocation( + fun build(): MeteredAllowance = + MeteredAllowance( checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedAllocationConfig", - cumulativeGroupedAllocationConfig, - ), checkRequired("itemId", itemId), + checkRequired("meteredAllowanceConfig", meteredAllowanceConfig), modelType, checkRequired("name", name), billableMetricId, @@ -27173,6 +42703,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -27181,16 +42712,26 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocation = apply { + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): MeteredAllowance = apply { if (validated) { return@apply } cadence().validate() - cumulativeGroupedAllocationConfig().validate() itemId() + meteredAllowanceConfig().validate() _modelType().let { - if (it != JsonValue.from("cumulative_grouped_allocation")) { + if (it != JsonValue.from("metered_allowance")) { throw OrbInvalidDataException("'modelType' is invalid, received $it") } } @@ -27206,6 +42747,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -27228,11 +42770,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + - (cumulativeGroupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - modelType.let { - if (it == JsonValue.from("cumulative_grouped_allocation")) 1 else 0 - } + + (meteredAllowanceConfig.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("metered_allowance")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -27245,6 +42785,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -27368,6 +42909,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -27407,60 +42958,76 @@ private constructor( override fun toString() = value.toString() } - /** Configuration for cumulative_grouped_allocation pricing */ - class CumulativeGroupedAllocationConfig + /** Configuration for metered_allowance pricing */ + class MeteredAllowanceConfig @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val cumulativeAllocation: JsonField, - private val groupAllocation: JsonField, + private val allowanceGroupingValue: JsonField, + private val consumptionGroupingValue: JsonField, private val groupingKey: JsonField, private val unitAmount: JsonField, + private val allowanceDisplayName: JsonField, + private val consumptionDisplayName: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - cumulativeAllocation: JsonField = JsonMissing.of(), - @JsonProperty("group_allocation") + allowanceGroupingValue: JsonField = JsonMissing.of(), + @JsonProperty("consumption_grouping_value") @ExcludeMissing - groupAllocation: JsonField = JsonMissing.of(), + consumptionGroupingValue: JsonField = JsonMissing.of(), @JsonProperty("grouping_key") @ExcludeMissing groupingKey: JsonField = JsonMissing.of(), @JsonProperty("unit_amount") @ExcludeMissing unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("allowance_display_name") + @ExcludeMissing + allowanceDisplayName: JsonField = JsonMissing.of(), + @JsonProperty("consumption_display_name") + @ExcludeMissing + consumptionDisplayName: JsonField = JsonMissing.of(), ) : this( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, mutableMapOf(), ) /** - * The overall allocation across all groups + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun cumulativeAllocation(): String = - cumulativeAllocation.getRequired("cumulative_allocation") + fun allowanceGroupingValue(): String = + allowanceGroupingValue.getRequired("allowance_grouping_value") /** - * The allocation per individual group + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an * unexpected value). */ - fun groupAllocation(): String = groupAllocation.getRequired("group_allocation") + fun consumptionGroupingValue(): String = + consumptionGroupingValue.getRequired("consumption_grouping_value") /** - * The event property used to group usage before applying allocations + * Event property used to partition the metric into consumption and allowance + * quantities (e.g. 'event_name'). The metric is queried with this key and the + * two values below select which partition is which. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -27469,7 +43036,7 @@ private constructor( fun groupingKey(): String = groupingKey.getRequired("grouping_key") /** - * The amount to charge for each unit outside of the allocation + * Per-unit price applied to gross consumption and to the allowance credit. * * @throws OrbInvalidDataException if the JSON field has an unexpected type or * is unexpectedly missing or null (e.g. if the server responded with an @@ -27478,24 +43045,42 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** - * Returns the raw JSON value of [cumulativeAllocation]. + * Sub-line label for the credit row (e.g. 'Up to 3x free egress'). * - * Unlike [cumulativeAllocation], this method doesn't throw if the JSON field + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun allowanceDisplayName(): Optional = + allowanceDisplayName.getOptional("allowance_display_name") + + /** + * Sub-line label for the gross consumption row (e.g. 'bytes gotten'). + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumptionDisplayName(): Optional = + consumptionDisplayName.getOptional("consumption_display_name") + + /** + * Returns the raw JSON value of [allowanceGroupingValue]. + * + * Unlike [allowanceGroupingValue], this method doesn't throw if the JSON field * has an unexpected type. */ - @JsonProperty("cumulative_allocation") + @JsonProperty("allowance_grouping_value") @ExcludeMissing - fun _cumulativeAllocation(): JsonField = cumulativeAllocation + fun _allowanceGroupingValue(): JsonField = allowanceGroupingValue /** - * Returns the raw JSON value of [groupAllocation]. + * Returns the raw JSON value of [consumptionGroupingValue]. * - * Unlike [groupAllocation], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [consumptionGroupingValue], this method doesn't throw if the JSON + * field has an unexpected type. */ - @JsonProperty("group_allocation") + @JsonProperty("consumption_grouping_value") @ExcludeMissing - fun _groupAllocation(): JsonField = groupAllocation + fun _consumptionGroupingValue(): JsonField = consumptionGroupingValue /** * Returns the raw JSON value of [groupingKey]. @@ -27517,6 +43102,26 @@ private constructor( @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + /** + * Returns the raw JSON value of [allowanceDisplayName]. + * + * Unlike [allowanceDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("allowance_display_name") + @ExcludeMissing + fun _allowanceDisplayName(): JsonField = allowanceDisplayName + + /** + * Returns the raw JSON value of [consumptionDisplayName]. + * + * Unlike [consumptionDisplayName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumption_display_name") + @ExcludeMissing + fun _consumptionDisplayName(): JsonField = consumptionDisplayName + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -27533,12 +43138,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedAllocationConfig]. + * [MeteredAllowanceConfig]. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` @@ -27546,61 +43151,75 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedAllocationConfig]. */ + /** A builder for [MeteredAllowanceConfig]. */ class Builder internal constructor() { - private var cumulativeAllocation: JsonField? = null - private var groupAllocation: JsonField? = null + private var allowanceGroupingValue: JsonField? = null + private var consumptionGroupingValue: JsonField? = null private var groupingKey: JsonField? = null private var unitAmount: JsonField? = null + private var allowanceDisplayName: JsonField = JsonMissing.of() + private var consumptionDisplayName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - cumulativeGroupedAllocationConfig: CumulativeGroupedAllocationConfig - ) = apply { - cumulativeAllocation = - cumulativeGroupedAllocationConfig.cumulativeAllocation - groupAllocation = cumulativeGroupedAllocationConfig.groupAllocation - groupingKey = cumulativeGroupedAllocationConfig.groupingKey - unitAmount = cumulativeGroupedAllocationConfig.unitAmount + internal fun from(meteredAllowanceConfig: MeteredAllowanceConfig) = apply { + allowanceGroupingValue = meteredAllowanceConfig.allowanceGroupingValue + consumptionGroupingValue = + meteredAllowanceConfig.consumptionGroupingValue + groupingKey = meteredAllowanceConfig.groupingKey + unitAmount = meteredAllowanceConfig.unitAmount + allowanceDisplayName = meteredAllowanceConfig.allowanceDisplayName + consumptionDisplayName = meteredAllowanceConfig.consumptionDisplayName additionalProperties = - cumulativeGroupedAllocationConfig.additionalProperties - .toMutableMap() + meteredAllowanceConfig.additionalProperties.toMutableMap() } - /** The overall allocation across all groups */ - fun cumulativeAllocation(cumulativeAllocation: String) = - cumulativeAllocation(JsonField.of(cumulativeAllocation)) + /** + * The grouping_key value whose summed quantity represents the allowance for + * this period (e.g. 'storage_snapshot' emitting 3 × avg storage). Capped at + * consumption — credit can never exceed actual usage. + */ + fun allowanceGroupingValue(allowanceGroupingValue: String) = + allowanceGroupingValue(JsonField.of(allowanceGroupingValue)) /** - * Sets [Builder.cumulativeAllocation] to an arbitrary JSON value. + * Sets [Builder.allowanceGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.cumulativeAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.allowanceGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun cumulativeAllocation(cumulativeAllocation: JsonField) = apply { - this.cumulativeAllocation = cumulativeAllocation - } + fun allowanceGroupingValue(allowanceGroupingValue: JsonField) = + apply { + this.allowanceGroupingValue = allowanceGroupingValue + } - /** The allocation per individual group */ - fun groupAllocation(groupAllocation: String) = - groupAllocation(JsonField.of(groupAllocation)) + /** + * The grouping_key value whose summed quantity represents consumption (e.g. + * 'download'). Charged at unit_amount. + */ + fun consumptionGroupingValue(consumptionGroupingValue: String) = + consumptionGroupingValue(JsonField.of(consumptionGroupingValue)) /** - * Sets [Builder.groupAllocation] to an arbitrary JSON value. + * Sets [Builder.consumptionGroupingValue] to an arbitrary JSON value. * - * You should usually call [Builder.groupAllocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.consumptionGroupingValue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun groupAllocation(groupAllocation: JsonField) = apply { - this.groupAllocation = groupAllocation - } + fun consumptionGroupingValue(consumptionGroupingValue: JsonField) = + apply { + this.consumptionGroupingValue = consumptionGroupingValue + } - /** The event property used to group usage before applying allocations */ + /** + * Event property used to partition the metric into consumption and + * allowance quantities (e.g. 'event_name'). The metric is queried with this + * key and the two values below select which partition is which. + */ fun groupingKey(groupingKey: String) = groupingKey(JsonField.of(groupingKey)) @@ -27615,7 +43234,9 @@ private constructor( this.groupingKey = groupingKey } - /** The amount to charge for each unit outside of the allocation */ + /** + * Per-unit price applied to gross consumption and to the allowance credit. + */ fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** @@ -27629,6 +43250,37 @@ private constructor( this.unitAmount = unitAmount } + /** Sub-line label for the credit row (e.g. 'Up to 3x free egress'). */ + fun allowanceDisplayName(allowanceDisplayName: String) = + allowanceDisplayName(JsonField.of(allowanceDisplayName)) + + /** + * Sets [Builder.allowanceDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.allowanceDisplayName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowanceDisplayName(allowanceDisplayName: JsonField) = apply { + this.allowanceDisplayName = allowanceDisplayName + } + + /** Sub-line label for the gross consumption row (e.g. 'bytes gotten'). */ + fun consumptionDisplayName(consumptionDisplayName: String) = + consumptionDisplayName(JsonField.of(consumptionDisplayName)) + + /** + * Sets [Builder.consumptionDisplayName] to an arbitrary JSON value. + * + * You should usually call [Builder.consumptionDisplayName] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumptionDisplayName(consumptionDisplayName: JsonField) = + apply { + this.consumptionDisplayName = consumptionDisplayName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -27652,41 +43304,55 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedAllocationConfig]. + * Returns an immutable instance of [MeteredAllowanceConfig]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .cumulativeAllocation() - * .groupAllocation() + * .allowanceGroupingValue() + * .consumptionGroupingValue() * .groupingKey() * .unitAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedAllocationConfig = - CumulativeGroupedAllocationConfig( - checkRequired("cumulativeAllocation", cumulativeAllocation), - checkRequired("groupAllocation", groupAllocation), + fun build(): MeteredAllowanceConfig = + MeteredAllowanceConfig( + checkRequired("allowanceGroupingValue", allowanceGroupingValue), + checkRequired("consumptionGroupingValue", consumptionGroupingValue), checkRequired("groupingKey", groupingKey), checkRequired("unitAmount", unitAmount), + allowanceDisplayName, + consumptionDisplayName, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): CumulativeGroupedAllocationConfig = apply { + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): MeteredAllowanceConfig = apply { if (validated) { return@apply } - cumulativeAllocation() - groupAllocation() + allowanceGroupingValue() + consumptionGroupingValue() groupingKey() unitAmount() + allowanceDisplayName() + consumptionDisplayName() validated = true } @@ -27706,30 +43372,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (cumulativeAllocation.asKnown().isPresent) 1 else 0) + - (if (groupAllocation.asKnown().isPresent) 1 else 0) + + (if (allowanceGroupingValue.asKnown().isPresent) 1 else 0) + + (if (consumptionGroupingValue.asKnown().isPresent) 1 else 0) + (if (groupingKey.asKnown().isPresent) 1 else 0) + - (if (unitAmount.asKnown().isPresent) 1 else 0) + (if (unitAmount.asKnown().isPresent) 1 else 0) + + (if (allowanceDisplayName.asKnown().isPresent) 1 else 0) + + (if (consumptionDisplayName.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is CumulativeGroupedAllocationConfig && - cumulativeAllocation == other.cumulativeAllocation && - groupAllocation == other.groupAllocation && + return other is MeteredAllowanceConfig && + allowanceGroupingValue == other.allowanceGroupingValue && + consumptionGroupingValue == other.consumptionGroupingValue && groupingKey == other.groupingKey && unitAmount == other.unitAmount && + allowanceDisplayName == other.allowanceDisplayName && + consumptionDisplayName == other.consumptionDisplayName && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - cumulativeAllocation, - groupAllocation, + allowanceGroupingValue, + consumptionGroupingValue, groupingKey, unitAmount, + allowanceDisplayName, + consumptionDisplayName, additionalProperties, ) } @@ -27737,7 +43409,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocationConfig{cumulativeAllocation=$cumulativeAllocation, groupAllocation=$groupAllocation, groupingKey=$groupingKey, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + "MeteredAllowanceConfig{allowanceGroupingValue=$allowanceGroupingValue, consumptionGroupingValue=$consumptionGroupingValue, groupingKey=$groupingKey, unitAmount=$unitAmount, allowanceDisplayName=$allowanceDisplayName, consumptionDisplayName=$consumptionDisplayName, additionalProperties=$additionalProperties}" } /** @@ -27807,6 +43479,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -27856,11 +43538,10 @@ private constructor( return true } - return other is CumulativeGroupedAllocation && + return other is MeteredAllowance && cadence == other.cadence && - cumulativeGroupedAllocationConfig == - other.cumulativeGroupedAllocationConfig && itemId == other.itemId && + meteredAllowanceConfig == other.meteredAllowanceConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && @@ -27874,6 +43555,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -27882,8 +43564,8 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( cadence, - cumulativeGroupedAllocationConfig, itemId, + meteredAllowanceConfig, modelType, name, billableMetricId, @@ -27897,6 +43579,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -27906,7 +43589,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedAllocation{cadence=$cadence, cumulativeGroupedAllocationConfig=$cumulativeGroupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MeteredAllowance{cadence=$cadence, itemId=$itemId, meteredAllowanceConfig=$meteredAllowanceConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class Percent @@ -27929,6 +43612,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -27987,6 +43671,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -28010,6 +43697,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -28168,6 +43856,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -28336,6 +44032,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -28409,6 +44115,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -28431,6 +44138,7 @@ private constructor( fixedPriceQuantity = percent.fixedPriceQuantity invoiceGroupingKey = percent.invoiceGroupingKey invoicingCycleConfiguration = percent.invoicingCycleConfiguration + licenseTypeId = percent.licenseTypeId metadata = percent.metadata referenceId = percent.referenceId additionalProperties = percent.additionalProperties.toMutableMap() @@ -28849,6 +44557,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -28945,6 +44674,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -28953,6 +44683,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Percent = apply { if (validated) { return@apply @@ -28978,6 +44718,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -29015,6 +44756,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -29138,6 +44880,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -29305,6 +45057,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): PercentConfig = apply { if (validated) { return@apply @@ -29418,6 +45180,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -29484,6 +45256,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -29507,6 +45280,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -29516,7 +45290,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Percent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, percentConfig=$percentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } class EventOutput @@ -29539,6 +45313,7 @@ private constructor( private val fixedPriceQuantity: JsonField, private val invoiceGroupingKey: JsonField, private val invoicingCycleConfiguration: JsonField, + private val licenseTypeId: JsonField, private val metadata: JsonField, private val referenceId: JsonField, private val additionalProperties: MutableMap, @@ -29597,6 +45372,9 @@ private constructor( @ExcludeMissing invoicingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("license_type_id") + @ExcludeMissing + licenseTypeId: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @@ -29620,6 +45398,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, mutableMapOf(), @@ -29779,6 +45558,14 @@ private constructor( fun invoicingCycleConfiguration(): Optional = invoicingCycleConfiguration.getOptional("invoicing_cycle_configuration") + /** + * The ID of the license type to associate with this price. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licenseTypeId(): Optional = licenseTypeId.getOptional("license_type_id") + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by @@ -29947,6 +45734,16 @@ private constructor( fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration + /** + * Returns the raw JSON value of [licenseTypeId]. + * + * Unlike [licenseTypeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("license_type_id") + @ExcludeMissing + fun _licenseTypeId(): JsonField = licenseTypeId + /** * Returns the raw JSON value of [metadata]. * @@ -30020,6 +45817,7 @@ private constructor( private var invoicingCycleConfiguration: JsonField = JsonMissing.of() + private var licenseTypeId: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -30042,6 +45840,7 @@ private constructor( fixedPriceQuantity = eventOutput.fixedPriceQuantity invoiceGroupingKey = eventOutput.invoiceGroupingKey invoicingCycleConfiguration = eventOutput.invoicingCycleConfiguration + licenseTypeId = eventOutput.licenseTypeId metadata = eventOutput.metadata referenceId = eventOutput.referenceId additionalProperties = eventOutput.additionalProperties.toMutableMap() @@ -30460,6 +46259,27 @@ private constructor( invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** The ID of the license type to associate with this price. */ + fun licenseTypeId(licenseTypeId: String?) = + licenseTypeId(JsonField.ofNullable(licenseTypeId)) + + /** + * Alias for calling [Builder.licenseTypeId] with `licenseTypeId.orElse(null)`. + */ + fun licenseTypeId(licenseTypeId: Optional) = + licenseTypeId(licenseTypeId.getOrNull()) + + /** + * Sets [Builder.licenseTypeId] to an arbitrary JSON value. + * + * You should usually call [Builder.licenseTypeId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licenseTypeId(licenseTypeId: JsonField) = apply { + this.licenseTypeId = licenseTypeId + } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can @@ -30556,6 +46376,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties.toMutableMap(), @@ -30564,6 +46385,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): EventOutput = apply { if (validated) { return@apply @@ -30589,6 +46420,7 @@ private constructor( fixedPriceQuantity() invoiceGroupingKey() invoicingCycleConfiguration().ifPresent { it.validate() } + licenseTypeId() metadata().ifPresent { it.validate() } referenceId() validated = true @@ -30626,6 +46458,7 @@ private constructor( (if (fixedPriceQuantity.asKnown().isPresent) 1 else 0) + (if (invoiceGroupingKey.asKnown().isPresent) 1 else 0) + (invoicingCycleConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (licenseTypeId.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (referenceId.asKnown().isPresent) 1 else 0) @@ -30749,6 +46582,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Cadence = apply { if (validated) { return@apply @@ -31024,6 +46867,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): EventOutputConfig = apply { if (validated) { return@apply @@ -31149,6 +47002,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't + * match its expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply @@ -31215,6 +47078,7 @@ private constructor( fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && + licenseTypeId == other.licenseTypeId && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties @@ -31238,6 +47102,7 @@ private constructor( fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, + licenseTypeId, metadata, referenceId, additionalProperties, @@ -31247,7 +47112,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "EventOutput{cadence=$cadence, eventOutputConfig=$eventOutputConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, conversionRateConfig=$conversionRateConfig, currency=$currency, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, licenseTypeId=$licenseTypeId, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -31263,6 +47128,7 @@ private constructor( externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && + metricParameterOverrides == other.metricParameterOverrides && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && @@ -31277,6 +47143,7 @@ private constructor( externalPriceId, fixedPriceQuantity, maximumAmount, + metricParameterOverrides, minimumAmount, price, priceId, @@ -31287,7 +47154,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" + "ReplacePrice{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, metricParameterOverrides=$metricParameterOverrides, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt index ebf98d213..2b1ff30ee 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfo.kt @@ -136,6 +136,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionTrialInfo = apply { if (validated) { return@apply 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 1c60f1d41..a58441577 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 @@ -493,6 +493,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply 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 33462fefb..26f3c357b 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 @@ -17,6 +17,12 @@ import kotlin.jvm.optionals.getOrNull * To be eligible, the subscription must currently be active and have a future cancellation. This * operation will turn on auto-renew, ensuring that the subscription does not end at the currently * scheduled cancellation time. + * + * Note: uncancellation is a lossy operation. Price intervals that were cut short by the + * cancellation are extended to infinity (original end dates are lost), and future intervals or + * phases scheduled after the cancellation time are permanently deleted. For complex subscriptions + * with phases or scheduled plan changes, consider creating a new plan change instead of + * uncancelling. */ class SubscriptionUnscheduleCancellationParams private constructor( 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 13ca8078a..1f40802e0 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 @@ -386,6 +386,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply 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 1fbcead0a..473f84184 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 @@ -751,6 +751,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -917,6 +926,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ChangeOption = apply { if (validated) { return@apply 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 bdc44097c..fa8a50138 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 @@ -772,6 +772,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -901,6 +910,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply 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 ff2720ffa..3b1030d5c 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 @@ -518,6 +518,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Body = apply { if (validated) { return@apply @@ -595,6 +604,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = trialEndDate.accept(new TrialEndDate.Visitor>() { + * @Override + * public Optional visitOffsetDateTime(OffsetDateTime offsetDateTime) { + * return Optional.of(offsetDateTime.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) @@ -604,6 +642,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TrialEndDate = apply { if (validated) { return@apply @@ -835,6 +882,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UnionMember1 = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt index 10bb453e5..dee354386 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt @@ -55,6 +55,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.withorb.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = subscriptionUsage.accept(new SubscriptionUsage.Visitor>() { + * @Override + * public Optional visitUngrouped(UngroupedSubscriptionUsage ungrouped) { + * return Optional.of(ungrouped.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OrbInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and the + * current variant is unknown. + */ fun accept(visitor: Visitor): T = when { ungrouped != null -> visitor.visitUngrouped(ungrouped) @@ -64,6 +93,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): SubscriptionUsage = apply { if (validated) { return@apply @@ -338,6 +375,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): UngroupedSubscriptionUsage = apply { if (validated) { return@apply @@ -575,6 +621,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -756,6 +812,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): BillableMetric = apply { if (validated) { return@apply @@ -1006,6 +1072,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Usage = apply { if (validated) { return@apply @@ -1152,6 +1228,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ViewMode = apply { if (validated) { return@apply @@ -1402,6 +1488,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): GroupedSubscriptionUsage = apply { if (validated) { return@apply @@ -1680,6 +1775,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Data = apply { if (validated) { return@apply @@ -1863,6 +1968,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): BillableMetric = apply { if (validated) { return@apply @@ -2075,6 +2190,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): MetricGroup = apply { if (validated) { return@apply @@ -2327,6 +2452,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): Usage = apply { if (validated) { return@apply @@ -2473,6 +2608,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match + * its expected type. + */ fun validate(): ViewMode = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt index 6a322311a..a45403602 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt @@ -187,6 +187,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Subscriptions = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt index 3d43c8e63..60529f967 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmount.kt @@ -220,6 +220,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): TaxAmount = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Threshold.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Threshold.kt index 215c8fb64..11a0cccb1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Threshold.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Threshold.kt @@ -133,6 +133,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Threshold = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Tier.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Tier.kt index c67409c2d..e4b3bae3c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Tier.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Tier.kt @@ -211,6 +211,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): Tier = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt index c9f3f0d44..64adbd7b5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TierSubLineItem.kt @@ -296,6 +296,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): TierSubLineItem = apply { if (validated) { return@apply @@ -525,6 +533,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): TierConfig = apply { if (validated) { return@apply @@ -658,6 +675,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Type = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt index 0f638ec12..8b39110ed 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfig.kt @@ -180,6 +180,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): TieredConfig = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt index 9a43ba19f..58719bae8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConversionRateConfig.kt @@ -177,6 +177,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): TieredConversionRateConfig = apply { if (validated) { return@apply @@ -290,6 +298,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ConversionRateType = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt index 9d1a3ddaf..0e7d2953c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt @@ -127,6 +127,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): TopLevelPingResponse = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt index 0fe0b864e..c271fa285 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpInvoiceSettings.kt @@ -261,6 +261,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): TopUpInvoiceSettings = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt index 45015c19c..09e16fe60 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt @@ -393,6 +393,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): TrialDiscount = apply { if (validated) { return@apply @@ -512,6 +520,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -752,6 +769,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -891,6 +917,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1020,6 +1056,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt index ffb642955..0e9c62a5c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfig.kt @@ -167,6 +167,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): UnitConfig = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt index 79c00daaf..2af230e5c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConversionRateConfig.kt @@ -176,6 +176,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): UnitConversionRateConfig = apply { if (validated) { return@apply @@ -289,6 +297,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): ConversionRateType = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt index 8487119b4..140004baa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscount.kt @@ -325,6 +325,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): UsageDiscount = apply { if (validated) { return@apply @@ -442,6 +450,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -682,6 +699,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -821,6 +847,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -950,6 +986,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt index c4eb3e081..86c8f66f9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountInterval.kt @@ -376,6 +376,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): UsageDiscountInterval = apply { if (validated) { return@apply @@ -495,6 +503,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): DiscountType = apply { if (validated) { return@apply @@ -735,6 +752,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Filter = apply { if (validated) { return@apply @@ -874,6 +900,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Field = apply { if (validated) { return@apply @@ -1003,6 +1039,16 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Operator = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt index 0132be6d3..432b645f7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidInitiatedLedgerEntry.kt @@ -686,6 +686,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): VoidInitiatedLedgerEntry = apply { if (validated) { return@apply @@ -831,6 +839,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryStatus = apply { if (validated) { return@apply @@ -951,6 +968,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryType = apply { if (validated) { return@apply @@ -1052,6 +1078,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt index d9778c263..96eb14338 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/VoidLedgerEntry.kt @@ -645,6 +645,14 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its expected + * type. + */ fun validate(): VoidLedgerEntry = apply { if (validated) { return@apply @@ -788,6 +796,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryStatus = apply { if (validated) { return@apply @@ -908,6 +925,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): EntryType = apply { if (validated) { return@apply @@ -1009,6 +1035,15 @@ private constructor( private var validated: Boolean = false + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OrbInvalidDataException if any value type in this object doesn't match its + * expected type. + */ fun validate(): Metadata = apply { if (validated) { return@apply 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 3dbc378d4..bfcc9586f 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 @@ -18,6 +18,12 @@ import com.withorb.api.models.AlertUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ interface AlertServiceAsync { /** 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 37fde9f01..a71e881cf 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 @@ -31,6 +31,12 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ class AlertServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AlertServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt index 967124bb3..2a0cb3a2e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsync.kt @@ -14,6 +14,11 @@ import com.withorb.api.services.async.beta.ExternalPlanIdServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface BetaServiceAsync { /** @@ -28,6 +33,11 @@ interface BetaServiceAsync { */ fun withOptions(modifier: Consumer): BetaServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdServiceAsync /** This endpoint allows the creation of a new plan version for an existing plan. */ @@ -115,6 +125,11 @@ interface BetaServiceAsync { */ fun withOptions(modifier: Consumer): BetaServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt index 9af837003..50f6461c4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/BetaServiceAsyncImpl.kt @@ -27,6 +27,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class BetaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BetaServiceAsync { @@ -43,6 +48,11 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): BetaServiceAsync = BetaServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync = externalPlanId override fun createPlanVersion( @@ -83,6 +93,11 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse = externalPlanId private val createPlanVersionHandler: Handler = 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 2fc6a156b..595e9b508 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 @@ -15,6 +15,12 @@ import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface CouponServiceAsync { /** @@ -29,6 +35,12 @@ interface CouponServiceAsync { */ fun withOptions(modifier: Consumer): CouponServiceAsync + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionServiceAsync /** @@ -49,8 +61,7 @@ interface CouponServiceAsync { * * The list of coupons is ordered starting from the most recently created coupon. The response * also includes `pagination_metadata`, which lets the caller retrieve the next page of results - * if they exist. More information about pagination can be found in the Pagination-metadata - * schema. + * if they exist. */ fun list(): CompletableFuture = list(CouponListParams.none()) @@ -154,6 +165,12 @@ interface CouponServiceAsync { modifier: Consumer ): CouponServiceAsync.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionServiceAsync.WithRawResponse /** 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 d25042cbd..e16d644bd 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 @@ -29,6 +29,12 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class CouponServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CouponServiceAsync { @@ -45,6 +51,12 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): CouponServiceAsync = CouponServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionServiceAsync = subscriptions override fun create( @@ -92,6 +104,12 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt index 05a0b24e9..4016f6c40 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsync.kt @@ -7,11 +7,17 @@ import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponse import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditBlockServiceAsync { /** @@ -108,6 +114,61 @@ interface CreditBlockServiceAsync { fun delete(blockId: String, requestOptions: RequestOptions): CompletableFuture = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + /** + * This endpoint returns the credit block and its associated purchasing invoices. + * + * If a credit block was purchased (as opposed to being manually added), this endpoint returns + * the invoices that were created to charge the customer for the credit block. For credit blocks + * with payment schedules spanning multiple periods (e.g., monthly payments over 12 months), + * multiple invoices will be returned. + * + * For credit blocks created by subscription allocation prices, this endpoint returns the + * subscription invoice containing the allocation line item that created the block. + * + * If the credit block was not purchased (e.g., manual increment), an empty invoices list is + * returned. + * + * **Note: This endpoint is currently experimental and its interface may change in future + * releases. Please contact support before building production integrations against this + * endpoint.** + */ + fun listInvoices(blockId: String): CompletableFuture = + listInvoices(blockId, CreditBlockListInvoicesParams.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + ): CompletableFuture = + listInvoices(blockId, params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams + ): CompletableFuture = + listInvoices(params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) + /** * A view of [CreditBlockServiceAsync] that provides access to raw HTTP responses for each * method. @@ -203,5 +264,48 @@ interface CreditBlockServiceAsync { requestOptions: RequestOptions, ): CompletableFuture = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /credit_blocks/{block_id}/invoices`, but is + * otherwise the same as [CreditBlockServiceAsync.listInvoices]. + */ + fun listInvoices( + blockId: String + ): CompletableFuture> = + listInvoices(blockId, CreditBlockListInvoicesParams.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + ): CompletableFuture> = + listInvoices(blockId, params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams + ): CompletableFuture> = + listInvoices(params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt index 55b2ff1c8..2d215be55 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncImpl.kt @@ -18,12 +18,18 @@ import com.withorb.api.core.http.json import com.withorb.api.core.http.parseable import com.withorb.api.core.prepareAsync import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditBlockServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockServiceAsync { @@ -50,6 +56,13 @@ class CreditBlockServiceAsyncImpl internal constructor(private val clientOptions // delete /credit_blocks/{block_id} withRawResponse().delete(params, requestOptions).thenAccept {} + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /credit_blocks/{block_id}/invoices + withRawResponse().listInvoices(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockServiceAsync.WithRawResponse { @@ -122,5 +135,38 @@ class CreditBlockServiceAsyncImpl internal constructor(private val clientOptions } } } + + private val listInvoicesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("credit_blocks", params._pathParam(0), "invoices") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listInvoicesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } 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 c5e361dde..b3a988db0 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 @@ -13,6 +13,10 @@ import com.withorb.api.models.CreditNoteListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ interface CreditNoteServiceAsync { /** 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 ab1a9466a..7bacce9cc 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 @@ -26,6 +26,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ class CreditNoteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteServiceAsync { 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 c81e266bf..64ac879c2 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 @@ -23,6 +23,24 @@ import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CustomerServiceAsync { /** @@ -37,10 +55,50 @@ interface CustomerServiceAsync { */ fun withOptions(modifier: Consumer): CustomerServiceAsync + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun costs(): CostServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditServiceAsync + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionServiceAsync /** @@ -68,8 +126,9 @@ interface CustomerServiceAsync { /** * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, * `email`, `email_delivery`, `tax_id`, `auto_collection`, `metadata`, `shipping_address`, - * `billing_address`, and `additional_emails` of an existing customer. Other fields on a - * customer are currently immutable. + * `billing_address`, `additional_emails`, and `currency` of an existing customer. `currency` + * can only be set if it has not already been set on the customer. Other fields on a customer + * are currently immutable. */ fun update(customerId: String): CompletableFuture = update(customerId, CustomerUpdateParams.none()) @@ -428,10 +487,50 @@ interface CustomerServiceAsync { modifier: Consumer ): CustomerServiceAsync.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun costs(): CostServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditServiceAsync.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionServiceAsync.WithRawResponse /** 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 e4c490df1..461b40230 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 @@ -39,6 +39,24 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CustomerServiceAsync { @@ -59,10 +77,50 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C override fun withOptions(modifier: Consumer): CustomerServiceAsync = CustomerServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun costs(): CostServiceAsync = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditServiceAsync = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionServiceAsync = balanceTransactions override fun create( @@ -156,10 +214,50 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun costs(): CostServiceAsync.WithRawResponse = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditServiceAsync.WithRawResponse = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionServiceAsync.WithRawResponse = balanceTransactions 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 cbc65eb3e..0a65ba125 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 @@ -18,6 +18,11 @@ import com.withorb.api.services.async.events.VolumeServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface EventServiceAsync { /** @@ -32,8 +37,18 @@ interface EventServiceAsync { */ fun withOptions(modifier: Consumer): EventServiceAsync + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun backfills(): BackfillServiceAsync + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun volume(): VolumeServiceAsync /** @@ -405,8 +420,18 @@ interface EventServiceAsync { modifier: Consumer ): EventServiceAsync.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun backfills(): BackfillServiceAsync.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun volume(): VolumeServiceAsync.WithRawResponse /** 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 782512a84..503600c4e 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 @@ -32,6 +32,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class EventServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EventServiceAsync { @@ -48,8 +53,18 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): EventServiceAsync = EventServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun backfills(): BackfillServiceAsync = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun volume(): VolumeServiceAsync = volume override fun update( @@ -101,8 +116,18 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun backfills(): BackfillServiceAsync.WithRawResponse = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun volume(): VolumeServiceAsync.WithRawResponse = volume private val updateHandler: Handler = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt index 6837fd01e..6973ff5f0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt @@ -10,6 +10,13 @@ import com.withorb.api.models.InvoiceLineItemCreateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceLineItemServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt index 58ac0b84d..475c73977 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncImpl.kt @@ -20,6 +20,13 @@ import com.withorb.api.models.InvoiceLineItemCreateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceLineItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceLineItemServiceAsync { 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 6cacdd7e3..2e906d543 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 @@ -13,6 +13,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPageAsync import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceListSummaryPageAsync @@ -24,6 +26,13 @@ import com.withorb.api.models.InvoiceVoidInvoiceParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceServiceAsync { /** @@ -49,13 +58,13 @@ interface InvoiceServiceAsync { ): CompletableFuture /** - * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and - * `invoice_date` properties on an invoice. If you pass null for the metadata value, it will - * clear any existing metadata for that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, + * and `auto_collection` properties on an invoice. If you pass null for the metadata value, it + * will clear any existing metadata for that invoice. * - * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, and - * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can - * only be modified for non-subscription invoices. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, + * `invoice_date`, and `auto_collection` can only be modified if the invoice is in a `draft` + * state. `invoice_date` can only be modified for non-subscription invoices. */ fun update(invoiceId: String): CompletableFuture = update(invoiceId, InvoiceUpdateParams.none()) @@ -101,6 +110,10 @@ interface InvoiceServiceAsync { * When fetching any `draft` invoices, this returns the last-computed invoice values for each * draft invoice, which may not always be up-to-date since Orb regularly refreshes invoices * asynchronously. + * + * If you don't need line item details, minimums, maximums, or discounts, prefer the + * [list invoices summary](/api-reference/invoice/list-invoices-summary) endpoint for better + * performance. */ fun list(): CompletableFuture = list(InvoiceListParams.none()) @@ -235,6 +248,52 @@ interface InvoiceServiceAsync { fun issue(invoiceId: String, requestOptions: RequestOptions): CompletableFuture = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * This endpoint allows an eligible invoice to be issued manually. This is only possible with + * invoices where status is `draft`, `will_auto_issue` is false, and an `eligible_to_issue_at` + * is a time in the past. Issuing an invoice could possibly trigger side effects, some of which + * could be customer-visible (e.g. sending emails, auto-collecting payment, syncing the invoice + * to external providers, etc). + * + * This is a lighter-weight alternative to the issue invoice endpoint, returning an invoice + * summary without any line item details. + */ + fun issueSummary(invoiceId: String): CompletableFuture = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + ): CompletableFuture = + issueSummary(invoiceId, params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams + ): CompletableFuture = issueSummary(params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * This is a lighter-weight endpoint that returns a list of all * [`Invoice`](/core-concepts#invoice) summaries for an account in a list format. @@ -298,24 +357,25 @@ interface InvoiceServiceAsync { ): CompletableFuture /** - * 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". + * This endpoint collects payment for an invoice. By default, it uses the customer's default + * payment method. Optionally, a shared payment token (SPT) can be provided to pay using + * agent-granted credentials instead. This action can only be taken on invoices with status + * "issued". */ - fun pay(invoiceId: String): CompletableFuture = pay(invoiceId, InvoicePayParams.none()) + fun pay(invoiceId: String, params: InvoicePayParams): CompletableFuture = + pay(invoiceId, params, RequestOptions.none()) /** @see pay */ fun pay( invoiceId: String, - params: InvoicePayParams = InvoicePayParams.none(), + params: InvoicePayParams, 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()) + fun pay(params: InvoicePayParams): CompletableFuture = + pay(params, RequestOptions.none()) /** @see pay */ fun pay( @@ -323,14 +383,6 @@ 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 to the `void` status. This can only be * done to invoices that are in the `issued` status. @@ -587,6 +639,49 @@ interface InvoiceServiceAsync { ): CompletableFuture> = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /invoices/summary/{invoice_id}/issue`, but is + * otherwise the same as [InvoiceServiceAsync.issueSummary]. + */ + fun issueSummary( + invoiceId: String + ): CompletableFuture> = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + ): CompletableFuture> = + issueSummary(invoiceId, params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams + ): CompletableFuture> = + issueSummary(params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices/summary`, but is otherwise the same as * [InvoiceServiceAsync.listSummary]. @@ -644,29 +739,19 @@ interface InvoiceServiceAsync { * Returns a raw HTTP response for `post /invoices/{invoice_id}/pay`, but is otherwise the * same as [InvoiceServiceAsync.pay]. */ - 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(), + params: InvoicePayParams, ): CompletableFuture> = pay(invoiceId, params, RequestOptions.none()) /** @see pay */ fun pay( + invoiceId: String, params: InvoicePayParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> = + pay(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) /** @see pay */ fun pay(params: InvoicePayParams): CompletableFuture> = @@ -674,10 +759,9 @@ interface InvoiceServiceAsync { /** @see pay */ fun pay( - invoiceId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - pay(invoiceId, InvoicePayParams.none(), requestOptions) + params: InvoicePayParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `post /invoices/{invoice_id}/void`, but is otherwise the 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 7ccb58e57..b27d13e8b 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 @@ -24,6 +24,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPageAsync import com.withorb.api.models.InvoiceListPageResponse import com.withorb.api.models.InvoiceListParams @@ -38,6 +40,13 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceServiceAsync { @@ -99,6 +108,13 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl // post /invoices/{invoice_id}/issue withRawResponse().issue(params, requestOptions).thenApply { it.parse() } + override fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /invoices/summary/{invoice_id}/issue + withRawResponse().issueSummary(params, requestOptions).thenApply { it.parse() } + override fun listSummary( params: InvoiceListSummaryParams, requestOptions: RequestOptions, @@ -368,6 +384,40 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl } } + private val issueSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun issueSummary( + params: InvoiceIssueSummaryParams, + 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) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("invoices", "summary", params._pathParam(0), "issue") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { issueSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val listSummaryHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -454,7 +504,7 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) .addPathSegments("invoices", params._pathParam(0), "pay") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) 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 6ba89b364..2620a5cda 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 @@ -15,6 +15,11 @@ import com.withorb.api.models.ItemUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for invoices + * and tax calculation purposes. + */ interface ItemServiceAsync { /** 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 d17818542..78159acd2 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 @@ -28,6 +28,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for invoices + * and tax calculation purposes. + */ class ItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ItemServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt new file mode 100644 index 000000000..57f0bf588 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsync.kt @@ -0,0 +1,343 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPageAsync +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.async.licenses.ExternalLicenseServiceAsync +import com.withorb.api.services.async.licenses.UsageServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface LicenseServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LicenseServiceAsync + + fun externalLicenses(): ExternalLicenseServiceAsync + + fun usage(): UsageServiceAsync + + /** + * This endpoint is used to create a new license for a user. + * + * If a start date is provided, the license will be activated at the **start** of the specified + * date in the customer's timezone. Otherwise, the activation time will default to the **start** + * of the current day in the customer's timezone. + */ + fun create(params: LicenseCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** This endpoint is used to fetch a license given an identifier. */ + fun retrieve(licenseId: String): CompletableFuture = + retrieve(licenseId, LicenseRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + ): CompletableFuture = + retrieve(licenseId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: LicenseRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** This endpoint returns a list of all licenses for a subscription. */ + fun list(params: LicenseListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This endpoint is used to deactivate an existing license. + * + * If an end date is provided, the license will be deactivated at the **start** of the specified + * date in the customer's timezone. Otherwise, the deactivation time will default to the **end** + * of the current day in the customer's timezone. + */ + fun deactivate(licenseId: String): CompletableFuture = + deactivate(licenseId, LicenseDeactivateParams.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + ): CompletableFuture = + deactivate(licenseId, params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see deactivate */ + fun deactivate(params: LicenseDeactivateParams): CompletableFuture = + deactivate(params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** This endpoint is used to fetch a license given an external license identifier. */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + ): CompletableFuture = + retrieveByExternalId(externalLicenseId, params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams + ): CompletableFuture = + retrieveByExternalId(params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [LicenseServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): LicenseServiceAsync.WithRawResponse + + fun externalLicenses(): ExternalLicenseServiceAsync.WithRawResponse + + fun usage(): UsageServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /licenses`, but is otherwise the same as + * [LicenseServiceAsync.create]. + */ + fun create( + params: LicenseCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}`, but is otherwise the same + * as [LicenseServiceAsync.retrieve]. + */ + fun retrieve( + licenseId: String + ): CompletableFuture> = + retrieve(licenseId, LicenseRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + ): CompletableFuture> = + retrieve(licenseId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: LicenseRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /licenses`, but is otherwise the same as + * [LicenseServiceAsync.list]. + */ + fun list( + params: LicenseListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /licenses/{license_id}/deactivate`, but is + * otherwise the same as [LicenseServiceAsync.deactivate]. + */ + fun deactivate( + licenseId: String + ): CompletableFuture> = + deactivate(licenseId, LicenseDeactivateParams.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + ): CompletableFuture> = + deactivate(licenseId, params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see deactivate */ + fun deactivate( + params: LicenseDeactivateParams + ): CompletableFuture> = + deactivate(params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /licenses/external_license_id/{external_license_id}`, but is otherwise the same as + * [LicenseServiceAsync.retrieveByExternalId]. + */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + ): CompletableFuture> = + retrieveByExternalId(externalLicenseId, params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams + ): CompletableFuture> = + retrieveByExternalId(params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt new file mode 100644 index 000000000..50d467a57 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseServiceAsyncImpl.kt @@ -0,0 +1,290 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPageAsync +import com.withorb.api.models.LicenseListPageResponse +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.async.licenses.ExternalLicenseServiceAsync +import com.withorb.api.services.async.licenses.ExternalLicenseServiceAsyncImpl +import com.withorb.api.services.async.licenses.UsageServiceAsync +import com.withorb.api.services.async.licenses.UsageServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class LicenseServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseServiceAsync { + + private val withRawResponse: LicenseServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val externalLicenses: ExternalLicenseServiceAsync by lazy { + ExternalLicenseServiceAsyncImpl(clientOptions) + } + + private val usage: UsageServiceAsync by lazy { UsageServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): LicenseServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LicenseServiceAsync = + LicenseServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun externalLicenses(): ExternalLicenseServiceAsync = externalLicenses + + override fun usage(): UsageServiceAsync = usage + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /licenses + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/{license_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: LicenseListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /licenses/{license_id}/deactivate + withRawResponse().deactivate(params, requestOptions).thenApply { it.parse() } + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/external_license_id/{external_license_id} + withRawResponse().retrieveByExternalId(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val externalLicenses: ExternalLicenseServiceAsync.WithRawResponse by lazy { + ExternalLicenseServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val usage: UsageServiceAsync.WithRawResponse by lazy { + UsageServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): LicenseServiceAsync.WithRawResponse = + LicenseServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun externalLicenses(): ExternalLicenseServiceAsync.WithRawResponse = + externalLicenses + + override fun usage(): UsageServiceAsync.WithRawResponse = usage + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseListPageAsync.builder() + .service(LicenseServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val deactivateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "deactivate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deactivateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_license_id", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt new file mode 100644 index 000000000..e0df3d1cc --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsync.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPageAsync +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +interface LicenseTypeServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LicenseTypeServiceAsync + + /** + * This endpoint is used to create a new license type. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun create(params: LicenseTypeCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This endpoint returns a license type identified by its license_type_id. + * + * Use this endpoint to retrieve details about a specific license type, including its name and + * grouping key. + */ + fun retrieve(licenseTypeId: String): CompletableFuture = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + ): CompletableFuture = + retrieve(licenseTypeId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * This endpoint returns a list of all license types configured for the account, ordered in + * ascending order by creation time. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun list(): CompletableFuture = list(LicenseTypeListParams.none()) + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(LicenseTypeListParams.none(), requestOptions) + + /** + * A view of [LicenseTypeServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): LicenseTypeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /license_types`, but is otherwise the same as + * [LicenseTypeServiceAsync.create]. + */ + fun create( + params: LicenseTypeCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /license_types/{license_type_id}`, but is otherwise + * the same as [LicenseTypeServiceAsync.retrieve]. + */ + fun retrieve( + licenseTypeId: String + ): CompletableFuture> = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + ): CompletableFuture> = + retrieve(licenseTypeId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /license_types`, but is otherwise the same as + * [LicenseTypeServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(LicenseTypeListParams.none()) + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(LicenseTypeListParams.none(), requestOptions) + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt new file mode 100644 index 000000000..4c82d5aae --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncImpl.kt @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPageAsync +import com.withorb.api.models.LicenseTypeListPageResponse +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeServiceAsync { + + private val withRawResponse: LicenseTypeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LicenseTypeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LicenseTypeServiceAsync = + LicenseTypeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /license_types + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /license_types/{license_type_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /license_types + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): LicenseTypeServiceAsync.WithRawResponse = + LicenseTypeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseTypeId", params.licenseTypeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseTypeListPageAsync.builder() + .service(LicenseTypeServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + } +} 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 7e15b6dc4..cbe72d849 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 @@ -14,6 +14,10 @@ import com.withorb.api.models.MetricUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ interface MetricServiceAsync { /** @@ -81,9 +85,8 @@ interface MetricServiceAsync { 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 - * item. + * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about + * the metrics including its name, description, and item. */ fun list(): CompletableFuture = list(MetricListParams.none()) @@ -103,8 +106,9 @@ interface MetricServiceAsync { list(MetricListParams.none(), requestOptions) /** - * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about - * the metrics including its name, description, and item. + * 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 + * item. */ fun fetch(metricId: String): CompletableFuture = fetch(metricId, MetricFetchParams.none()) 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 756da69a9..773ae6bc0 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 @@ -27,6 +27,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ class MetricServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MetricServiceAsync { 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 9accb5d87..baa7d1423 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 @@ -16,6 +16,11 @@ import com.withorb.api.services.async.plans.MigrationServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface PlanServiceAsync { /** @@ -30,8 +35,18 @@ interface PlanServiceAsync { */ fun withOptions(modifier: Consumer): PlanServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdServiceAsync + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun migrations(): MigrationServiceAsync /** This endpoint allows creation of plans including their prices. */ @@ -45,8 +60,8 @@ interface PlanServiceAsync { ): CompletableFuture /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing - * plan. + * This endpoint can be used to update the `external_plan_id`, `description`, and `metadata` of + * an existing plan. * * Other fields on a plan are currently immutable. */ @@ -156,8 +171,18 @@ interface PlanServiceAsync { */ fun withOptions(modifier: Consumer): PlanServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun migrations(): MigrationServiceAsync.WithRawResponse /** 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 ae6338a27..8bd4bdd34 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 @@ -31,6 +31,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class PlanServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PlanServiceAsync { @@ -51,8 +56,18 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): PlanServiceAsync = PlanServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync = externalPlanId + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun migrations(): MigrationServiceAsync = migrations override fun create( @@ -104,8 +119,18 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse = externalPlanId + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun migrations(): MigrationServiceAsync.WithRawResponse = migrations private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) 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 a1b0957b6..c4f4831fa 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 @@ -5,6 +5,32 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.NewFloatingBulkPrice +import com.withorb.api.models.NewFloatingBulkWithProrationPrice +import com.withorb.api.models.NewFloatingCumulativeGroupedBulkPrice +import com.withorb.api.models.NewFloatingGroupedAllocationPrice +import com.withorb.api.models.NewFloatingGroupedTieredPackagePrice +import com.withorb.api.models.NewFloatingGroupedTieredPrice +import com.withorb.api.models.NewFloatingGroupedWithMeteredMinimumPrice +import com.withorb.api.models.NewFloatingGroupedWithProratedMinimumPrice +import com.withorb.api.models.NewFloatingMatrixPrice +import com.withorb.api.models.NewFloatingMatrixWithAllocationPrice +import com.withorb.api.models.NewFloatingMatrixWithDisplayNamePrice +import com.withorb.api.models.NewFloatingMaxGroupTieredPackagePrice +import com.withorb.api.models.NewFloatingMinimumCompositePrice +import com.withorb.api.models.NewFloatingPackagePrice +import com.withorb.api.models.NewFloatingPackageWithAllocationPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithTieredPricingPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithUnitPricingPrice +import com.withorb.api.models.NewFloatingThresholdTotalAmountPrice +import com.withorb.api.models.NewFloatingTieredPackagePrice +import com.withorb.api.models.NewFloatingTieredPackageWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredPrice +import com.withorb.api.models.NewFloatingTieredWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredWithProrationPrice +import com.withorb.api.models.NewFloatingUnitPrice +import com.withorb.api.models.NewFloatingUnitWithPercentPrice +import com.withorb.api.models.NewFloatingUnitWithProrationPrice import com.withorb.api.models.Price import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams @@ -21,6 +47,18 @@ import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface PriceServiceAsync { /** @@ -35,6 +73,18 @@ interface PriceServiceAsync { */ fun withOptions(modifier: Consumer): PriceServiceAsync + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdServiceAsync /** @@ -58,228 +108,1168 @@ interface PriceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * 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(priceId: String): CompletableFuture = - update(priceId, PriceUpdateParams.none()) - - /** @see update */ - fun update( - priceId: String, - params: PriceUpdateParams = PriceUpdateParams.none(), + /** @see create */ + fun create( + body: PriceCreateParams.Body, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = - update(params.toBuilder().priceId(priceId).build(), requestOptions) + create(PriceCreateParams.builder().body(body).build(), requestOptions) - /** @see update */ - fun update( - priceId: String, - params: PriceUpdateParams = PriceUpdateParams.none(), - ): CompletableFuture = update(priceId, params, RequestOptions.none()) + /** @see create */ + fun create(body: PriceCreateParams.Body): CompletableFuture = + create(body, RequestOptions.none()) - /** @see update */ - fun update( - params: PriceUpdateParams, + /** @see create */ + fun create( + unit: NewFloatingUnitPrice, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) - /** @see update */ - fun update(params: PriceUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + /** @see create */ + fun create(unit: NewFloatingUnitPrice): CompletableFuture = + create(unit, RequestOptions.none()) - /** @see update */ - fun update(priceId: String, requestOptions: RequestOptions): CompletableFuture = - update(priceId, PriceUpdateParams.none(), requestOptions) + /** @see create */ + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) - /** - * This endpoint is used to list all add-on prices created using the - * [price creation endpoint](/api-reference/price/create-price). - */ - fun list(): CompletableFuture = list(PriceListParams.none()) + /** @see create */ + fun create(tiered: NewFloatingTieredPrice): CompletableFuture = + create(tiered, RequestOptions.none()) - /** @see list */ - fun list( - params: PriceListParams = PriceListParams.none(), + /** @see create */ + fun create( + bulk: NewFloatingBulkPrice, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) - /** @see list */ - fun list( - params: PriceListParams = PriceListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + /** @see create */ + fun create(bulk: NewFloatingBulkPrice): CompletableFuture = + create(bulk, RequestOptions.none()) - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(PriceListParams.none(), requestOptions) + /** @see create */ + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) - /** - * [NOTE] It is recommended to use the `/v1/prices/evaluate` which offers further functionality, - * such as multiple prices, inline price definitions, and querying over preview events. - * - * This endpoint is used to evaluate the output of a price for a given customer and time range. - * It enables filtering and grouping the output using - * [computed properties](/extensibility/advanced-metrics#computed-properties), supporting the - * following workflows: - * 1. Showing detailed usage and costs to the end customer. - * 2. Auditing subtotals on invoice line items. - * - * For these workflows, the expressiveness of computed properties in both the filters and - * grouping is critical. For example, if you'd like to show your customer their usage grouped by - * hour and another property, you can do so with the following `grouping_keys`: - * `["hour_floor_timestamp_millis(timestamp_millis)", "my_property"]`. If you'd like to examine - * a customer's usage for a specific property value, you can do so with the following `filter`: - * `my_property = 'foo' AND my_other_property = 'bar'`. - * - * By default, the start of the time range must be no more than 100 days ago and the length of - * 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 create */ + fun create(bulkWithFilters: PriceCreateParams.Body.BulkWithFilters): CompletableFuture = + create(bulkWithFilters, RequestOptions.none()) - /** @see evaluate */ - fun evaluate( - priceId: String, - params: PriceEvaluateParams, + /** @see create */ + fun create( + package_: NewFloatingPackagePrice, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - evaluate(params.toBuilder().priceId(priceId).build(), requestOptions) + ): CompletableFuture = create(PriceCreateParams.Body.ofPackage(package_), requestOptions) - /** @see evaluate */ - fun evaluate(params: PriceEvaluateParams): CompletableFuture = - evaluate(params, RequestOptions.none()) + /** @see create */ + fun create(package_: NewFloatingPackagePrice): CompletableFuture = + create(package_, RequestOptions.none()) - /** @see evaluate */ - fun evaluate( - params: PriceEvaluateParams, + /** @see create */ + fun create( + matrix: NewFloatingMatrixPrice, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) - /** - * This endpoint is used to evaluate the output of price(s) for a given customer and time range - * over ingested events. It enables filtering and grouping the output using - * [computed properties](/extensibility/advanced-metrics#computed-properties), supporting the - * following workflows: - * 1. Showing detailed usage and costs to the end customer. - * 2. Auditing subtotals on invoice line items. - * - * For these workflows, the expressiveness of computed properties in both the filters and - * grouping is critical. For example, if you'd like to show your customer their usage grouped by - * hour and another property, you can do so with the following `grouping_keys`: - * `["hour_floor_timestamp_millis(timestamp_millis)", "my_property"]`. If you'd like to examine - * a customer's usage for a specific property value, you can do so with the following `filter`: - * `my_property = 'foo' AND my_other_property = 'bar'`. - * - * Prices may either reference existing prices in your Orb account or be defined inline in the - * request body. Up to 100 prices can be evaluated in a single request. - * - * Prices are evaluated on ingested events and the start of the time range must be no more than - * 100 days ago. To evaluate based off a set of provided events, the - * [evaluate preview events](/api-reference/price/evaluate-preview-events) endpoint can be used - * instead. - * - * Note that this is a POST endpoint rather than a GET endpoint because it employs a JSON body - * rather than query parameters. - */ - fun evaluateMultiple( - params: PriceEvaluateMultipleParams - ): CompletableFuture = - evaluateMultiple(params, RequestOptions.none()) + /** @see create */ + fun create(matrix: NewFloatingMatrixPrice): CompletableFuture = + create(matrix, RequestOptions.none()) - /** @see evaluateMultiple */ - fun evaluateMultiple( - params: PriceEvaluateMultipleParams, + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture = + create(PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), requestOptions) - /** - * This endpoint evaluates prices on preview events instead of actual usage, making it ideal for - * building price calculators and cost estimation tools. You can filter and group results using - * [computed properties](/extensibility/advanced-metrics#computed-properties) to analyze pricing - * across different dimensions. - * - * Prices may either reference existing prices in your Orb account or be defined inline in the - * request body. The endpoint has the following limitations: - * 1. Up to 100 prices can be evaluated in a single request. - * 2. Up to 500 preview events can be provided in a single request. - * - * A top-level customer_id is required to evaluate the preview events. Additionally, all events - * without a customer_id will have the top-level customer_id added. - * - * Note that this is a POST endpoint rather than a GET endpoint because it employs a JSON body - * rather than query parameters. - */ - fun evaluatePreviewEvents( - params: PriceEvaluatePreviewEventsParams - ): CompletableFuture = - evaluatePreviewEvents(params, RequestOptions.none()) + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice + ): CompletableFuture = create(thresholdTotalAmount, RequestOptions.none()) - /** @see evaluatePreviewEvents */ - fun evaluatePreviewEvents( - params: PriceEvaluatePreviewEventsParams, + /** @see create */ + fun create( + tieredPackage: NewFloatingTieredPackagePrice, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture = + create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) - /** This endpoint returns a price given an identifier. */ - fun fetch(priceId: String): CompletableFuture = fetch(priceId, PriceFetchParams.none()) + /** @see create */ + fun create(tieredPackage: NewFloatingTieredPackagePrice): CompletableFuture = + create(tieredPackage, RequestOptions.none()) - /** @see fetch */ - fun fetch( - priceId: String, - params: PriceFetchParams = PriceFetchParams.none(), + /** @see create */ + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = fetch(params.toBuilder().priceId(priceId).build(), requestOptions) + ): CompletableFuture = + create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) - /** @see fetch */ - fun fetch( - priceId: String, - params: PriceFetchParams = PriceFetchParams.none(), - ): CompletableFuture = fetch(priceId, params, RequestOptions.none()) + /** @see create */ + fun create(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): CompletableFuture = + create(tieredWithMinimum, RequestOptions.none()) - /** @see fetch */ - fun fetch( - params: PriceFetchParams, + /** @see create */ + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture = + create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) - /** @see fetch */ - fun fetch(params: PriceFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + /** @see create */ + fun create(groupedTiered: NewFloatingGroupedTieredPrice): CompletableFuture = + create(groupedTiered, RequestOptions.none()) - /** @see fetch */ - fun fetch(priceId: String, requestOptions: RequestOptions): CompletableFuture = - fetch(priceId, PriceFetchParams.none(), requestOptions) + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) - /** A view of [PriceServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice + ): CompletableFuture = create(tieredPackageWithMinimum, RequestOptions.none()) - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): PriceServiceAsync.WithRawResponse + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) - fun externalPriceId(): ExternalPriceIdServiceAsync.WithRawResponse + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ): CompletableFuture = create(packageWithAllocation, RequestOptions.none()) - /** - * Returns a raw HTTP response for `post /prices`, but is otherwise the same as - * [PriceServiceAsync.create]. - */ - fun create(params: PriceCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + /** @see create */ + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) - /** @see create */ - fun create( - params: PriceCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + /** @see create */ + fun create(unitWithPercent: NewFloatingUnitWithPercentPrice): CompletableFuture = + create(unitWithPercent, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), requestOptions) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): CompletableFuture = create(matrixWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithThresholdDiscounts: PriceCreateParams.Body.MatrixWithThresholdDiscounts, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithThresholdDiscounts: PriceCreateParams.Body.MatrixWithThresholdDiscounts + ): CompletableFuture = create(matrixWithThresholdDiscounts, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), requestOptions) + + /** @see create */ + fun create(tieredWithProration: NewFloatingTieredWithProrationPrice): CompletableFuture = + create(tieredWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + fun create(unitWithProration: NewFloatingUnitWithProrationPrice): CompletableFuture = + create(unitWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + fun create(groupedAllocation: NewFloatingGroupedAllocationPrice): CompletableFuture = + create(groupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + fun create(bulkWithProration: NewFloatingBulkWithProrationPrice): CompletableFuture = + create(bulkWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice + ): CompletableFuture = create(groupedWithProratedMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice + ): CompletableFuture = create(groupedWithMeteredMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds + ): CompletableFuture = create(groupedWithMinMaxThresholds, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + ): CompletableFuture = create(matrixWithDisplayName, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), requestOptions) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice + ): CompletableFuture = create(groupedTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): CompletableFuture = create(maxGroupTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice + ): CompletableFuture = create(scalableMatrixWithUnitPricing, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice + ): CompletableFuture = create(scalableMatrixWithTieredPricing, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice + ): CompletableFuture = create(cumulativeGroupedBulk, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation + ): CompletableFuture = create(cumulativeGroupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + dailyCreditAllowance: PriceCreateParams.Body.DailyCreditAllowance, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofDailyCreditAllowance(dailyCreditAllowance), requestOptions) + + /** @see create */ + fun create( + dailyCreditAllowance: PriceCreateParams.Body.DailyCreditAllowance + ): CompletableFuture = create(dailyCreditAllowance, RequestOptions.none()) + + /** @see create */ + fun create( + meteredAllowance: PriceCreateParams.Body.MeteredAllowance, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofMeteredAllowance(meteredAllowance), requestOptions) + + /** @see create */ + fun create( + meteredAllowance: PriceCreateParams.Body.MeteredAllowance + ): CompletableFuture = create(meteredAllowance, RequestOptions.none()) + + /** @see create */ + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + fun create(minimumComposite: NewFloatingMinimumCompositePrice): CompletableFuture = + create(minimumComposite, RequestOptions.none()) + + /** @see create */ + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + fun create(percent: PriceCreateParams.Body.Percent): CompletableFuture = + create(percent, RequestOptions.none()) + + /** @see create */ + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + + /** @see create */ + fun create(eventOutput: PriceCreateParams.Body.EventOutput): CompletableFuture = + create(eventOutput, RequestOptions.none()) + + /** + * 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(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( + params: PriceUpdateParams, + 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). + */ + fun list(): CompletableFuture = list(PriceListParams.none()) + + /** @see list */ + fun list( + params: PriceListParams = PriceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: PriceListParams = PriceListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(PriceListParams.none(), requestOptions) + + /** + * [NOTE] It is recommended to use the `/v1/prices/evaluate` which offers further functionality, + * such as multiple prices, inline price definitions, and querying over preview events. + * + * This endpoint is used to evaluate the output of a price for a given customer and time range. + * It enables filtering and grouping the output using + * [computed properties](/extensibility/advanced-metrics#computed-properties), supporting the + * following workflows: + * 1. Showing detailed usage and costs to the end customer. + * 2. Auditing subtotals on invoice line items. + * + * For these workflows, the expressiveness of computed properties in both the filters and + * grouping is critical. For example, if you'd like to show your customer their usage grouped by + * hour and another property, you can do so with the following `grouping_keys`: + * `["hour_floor_timestamp_millis(timestamp_millis)", "my_property"]`. If you'd like to examine + * a customer's usage for a specific property value, you can do so with the following `filter`: + * `my_property = 'foo' AND my_other_property = 'bar'`. + * + * By default, the start of the time range must be no more than 100 days ago and the length of + * 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()) + + /** @see evaluate */ + fun evaluate( + params: PriceEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This endpoint is used to evaluate the output of price(s) for a given customer and time range + * over ingested events. It enables filtering and grouping the output using + * [computed properties](/extensibility/advanced-metrics#computed-properties), supporting the + * following workflows: + * 1. Showing detailed usage and costs to the end customer. + * 2. Auditing subtotals on invoice line items. + * + * For these workflows, the expressiveness of computed properties in both the filters and + * grouping is critical. For example, if you'd like to show your customer their usage grouped by + * hour and another property, you can do so with the following `grouping_keys`: + * `["hour_floor_timestamp_millis(timestamp_millis)", "my_property"]`. If you'd like to examine + * a customer's usage for a specific property value, you can do so with the following `filter`: + * `my_property = 'foo' AND my_other_property = 'bar'`. + * + * Prices may either reference existing prices in your Orb account or be defined inline in the + * request body. Up to 100 prices can be evaluated in a single request. + * + * Prices are evaluated on ingested events and the start of the time range must be no more than + * 100 days ago. To evaluate based off a set of provided events, the + * [evaluate preview events](/api-reference/price/evaluate-preview-events) endpoint can be used + * instead. + * + * Note that this is a POST endpoint rather than a GET endpoint because it employs a JSON body + * rather than query parameters. + */ + fun evaluateMultiple( + params: PriceEvaluateMultipleParams + ): CompletableFuture = + evaluateMultiple(params, RequestOptions.none()) + + /** @see evaluateMultiple */ + fun evaluateMultiple( + params: PriceEvaluateMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This endpoint evaluates prices on preview events instead of actual usage, making it ideal for + * building price calculators and cost estimation tools. You can filter and group results using + * [computed properties](/extensibility/advanced-metrics#computed-properties) to analyze pricing + * across different dimensions. + * + * Prices may either reference existing prices in your Orb account or be defined inline in the + * request body. The endpoint has the following limitations: + * 1. Up to 100 prices can be evaluated in a single request. + * 2. Up to 500 preview events can be provided in a single request. + * + * A top-level customer_id is required to evaluate the preview events. Additionally, all events + * without a customer_id will have the top-level customer_id added. + * + * Note that this is a POST endpoint rather than a GET endpoint because it employs a JSON body + * rather than query parameters. + */ + fun evaluatePreviewEvents( + params: PriceEvaluatePreviewEventsParams + ): CompletableFuture = + evaluatePreviewEvents(params, RequestOptions.none()) + + /** @see evaluatePreviewEvents */ + fun evaluatePreviewEvents( + params: PriceEvaluatePreviewEventsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** This endpoint returns a price given an identifier. */ + 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( + params: PriceFetchParams, + 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 { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PriceServiceAsync.WithRawResponse + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun externalPriceId(): ExternalPriceIdServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /prices`, but is otherwise the same as + * [PriceServiceAsync.create]. + */ + fun create(params: PriceCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: PriceCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + fun create(body: PriceCreateParams.Body): CompletableFuture> = + create(body, RequestOptions.none()) + + /** @see create */ + fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + fun create(unit: NewFloatingUnitPrice): CompletableFuture> = + create(unit, RequestOptions.none()) + + /** @see create */ + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + fun create(tiered: NewFloatingTieredPrice): CompletableFuture> = + create(tiered, RequestOptions.none()) + + /** @see create */ + fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + fun create(bulk: NewFloatingBulkPrice): CompletableFuture> = + create(bulk, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters + ): CompletableFuture> = + create(bulkWithFilters, RequestOptions.none()) + + /** @see create */ + fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + fun create(package_: NewFloatingPackagePrice): CompletableFuture> = + create(package_, RequestOptions.none()) + + /** @see create */ + fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + fun create(matrix: NewFloatingMatrixPrice): CompletableFuture> = + create(matrix, RequestOptions.none()) + + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), + requestOptions, + ) + + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice + ): CompletableFuture> = + create(thresholdTotalAmount, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + fun create( + tieredPackage: NewFloatingTieredPackagePrice + ): CompletableFuture> = create(tieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice + ): CompletableFuture> = + create(tieredWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + fun create( + groupedTiered: NewFloatingGroupedTieredPrice + ): CompletableFuture> = create(groupedTiered, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice + ): CompletableFuture> = + create(tieredPackageWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ): CompletableFuture> = + create(packageWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice + ): CompletableFuture> = + create(unitWithPercent, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): CompletableFuture> = + create(matrixWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithThresholdDiscounts: PriceCreateParams.Body.MatrixWithThresholdDiscounts, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithThresholdDiscounts: PriceCreateParams.Body.MatrixWithThresholdDiscounts + ): CompletableFuture> = + create(matrixWithThresholdDiscounts, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), + requestOptions, + ) + + /** @see create */ + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice + ): CompletableFuture> = + create(tieredWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice + ): CompletableFuture> = + create(unitWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice + ): CompletableFuture> = + create(groupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice + ): CompletableFuture> = + create(bulkWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice + ): CompletableFuture> = + create(groupedWithProratedMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice + ): CompletableFuture> = + create(groupedWithMeteredMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds + ): CompletableFuture> = + create(groupedWithMinMaxThresholds, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + ): CompletableFuture> = + create(matrixWithDisplayName, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), + requestOptions, + ) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice + ): CompletableFuture> = + create(groupedTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): CompletableFuture> = + create(maxGroupTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice + ): CompletableFuture> = + create(scalableMatrixWithUnitPricing, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice + ): CompletableFuture> = + create(scalableMatrixWithTieredPricing, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice + ): CompletableFuture> = + create(cumulativeGroupedBulk, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation + ): CompletableFuture> = + create(cumulativeGroupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + dailyCreditAllowance: PriceCreateParams.Body.DailyCreditAllowance, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + PriceCreateParams.Body.ofDailyCreditAllowance(dailyCreditAllowance), + requestOptions, + ) + + /** @see create */ + fun create( + dailyCreditAllowance: PriceCreateParams.Body.DailyCreditAllowance + ): CompletableFuture> = + create(dailyCreditAllowance, RequestOptions.none()) + + /** @see create */ + fun create( + meteredAllowance: PriceCreateParams.Body.MeteredAllowance, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofMeteredAllowance(meteredAllowance), requestOptions) + + /** @see create */ + fun create( + meteredAllowance: PriceCreateParams.Body.MeteredAllowance + ): CompletableFuture> = + create(meteredAllowance, RequestOptions.none()) + + /** @see create */ + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + fun create( + minimumComposite: NewFloatingMinimumCompositePrice + ): CompletableFuture> = + create(minimumComposite, RequestOptions.none()) + + /** @see create */ + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + fun create( + percent: PriceCreateParams.Body.Percent + ): CompletableFuture> = create(percent, RequestOptions.none()) + + /** @see create */ + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + + /** @see create */ + fun create( + eventOutput: PriceCreateParams.Body.EventOutput + ): CompletableFuture> = create(eventOutput, RequestOptions.none()) /** * Returns a raw HTTP response for `put /prices/{price_id}`, but is otherwise the same as 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 e7573d2e5..bb0b1c978 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 @@ -35,6 +35,18 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class PriceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PriceServiceAsync { @@ -51,6 +63,18 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): PriceServiceAsync = PriceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdServiceAsync = externalPriceId override fun create( @@ -119,6 +143,18 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdServiceAsync.WithRawResponse = externalPriceId 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 5f6668bcf..96f9a81ec 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 @@ -487,9 +487,9 @@ interface SubscriptionServiceAsync { * units rather than a currency). * * The semantics of this endpoint exactly mirror those of - * [fetching a customer's costs](fetch-customer-costs). Use this endpoint to limit your analysis - * 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). + * [fetching a customer's costs](/api-reference/customer/fetch-customer-costs). Use this + * endpoint to limit your analysis 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()) @@ -1141,6 +1141,12 @@ interface SubscriptionServiceAsync { * To be eligible, the subscription must currently be active and have a future cancellation. * This operation will turn on auto-renew, ensuring that the subscription does not end at the * currently scheduled cancellation time. + * + * Note: uncancellation is a lossy operation. Price intervals that were cut short by the + * cancellation are extended to infinity (original end dates are lost), and future intervals or + * phases scheduled after the cancellation time are permanently deleted. For complex + * subscriptions with phases or scheduled plan changes, consider creating a new plan change + * instead of uncancelling. */ fun unscheduleCancellation(subscriptionId: String): CompletableFuture = unscheduleCancellation(subscriptionId, SubscriptionUnscheduleCancellationParams.none()) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt index d61e2b77c..03ae4cc12 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsync.kt @@ -13,6 +13,11 @@ import com.withorb.api.models.PlanVersion import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface ExternalPlanIdServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt index 3d41085ce..ccc0cad47 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncImpl.kt @@ -25,6 +25,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class ExternalPlanIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdServiceAsync { 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 30c2d43df..676d2e207 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 @@ -10,6 +10,12 @@ import com.withorb.api.models.CouponSubscriptionListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface SubscriptionServiceAsync { /** 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 1695a6e13..7963b5f8b 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 @@ -22,6 +22,12 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class SubscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionServiceAsync { 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 8fa16a1ff..c50d2d28e 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 @@ -12,6 +12,24 @@ import com.withorb.api.models.CustomerBalanceTransactionListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface BalanceTransactionServiceAsync { /** 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 a9c5ec052..c49f3a2bf 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 @@ -25,6 +25,24 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class BalanceTransactionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionServiceAsync { 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 45db99c9b..8e643fa93 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 @@ -12,6 +12,24 @@ import com.withorb.api.models.CustomerCostListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CostServiceAsync { /** 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 3c1970d8c..f5288571b 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 @@ -23,6 +23,24 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CostServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CostServiceAsync { 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 59bc036ab..5491d9b73 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 @@ -14,6 +14,10 @@ import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditServiceAsync { /** @@ -28,8 +32,16 @@ interface CreditServiceAsync { */ fun withOptions(modifier: Consumer): CreditServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerServiceAsync + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpServiceAsync /** @@ -40,6 +52,11 @@ interface CreditServiceAsync { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun list(customerId: String): CompletableFuture = list(customerId, CustomerCreditListParams.none()) @@ -84,6 +101,11 @@ interface CreditServiceAsync { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun listByExternalId( externalCustomerId: String @@ -145,8 +167,16 @@ interface CreditServiceAsync { modifier: Consumer ): CreditServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerServiceAsync.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpServiceAsync.WithRawResponse /** 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 41f0ffa95..37b2d2a98 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 @@ -29,6 +29,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditServiceAsync { @@ -45,8 +49,16 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): CreditServiceAsync = CreditServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerServiceAsync = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpServiceAsync = topUps override fun list( @@ -84,8 +96,16 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerServiceAsync.WithRawResponse = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpServiceAsync.WithRawResponse = topUps private val listHandler: Handler = 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 bee830085..c92797916 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 @@ -16,6 +16,10 @@ import com.withorb.api.models.CustomerCreditLedgerListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface LedgerServiceAsync { /** @@ -54,10 +58,8 @@ interface LedgerServiceAsync { * * As usage for a customer is reported into Orb, credits may be deducted according to the * customer's plan configuration. An automated deduction of this type will result in a ledger - * entry, also with a starting and ending balance. In order to provide better tracing - * capabilities for automatic deductions, Orb always associates each automatic deduction with - * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place - * and to ensure that credits are never deducted without an associated usage event. + * entry, also with a starting and ending balance. Each day's usage for a particular price, + * invoice, and block will be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring * credit block* first in order to ensure that all credits are utilized appropriately. As an @@ -181,10 +183,23 @@ interface LedgerServiceAsync { * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying - * the cost basis with the number of credit units added. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits - * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. + * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. A + * `decrement` entry records credits as usage and immediately recognizes revenue at the block's + * `per_unit_cost_basis`. + * + * For most credit removals, use `void` (no revenue impact) or `expiration_change` (revenue + * recognized on expiration) instead. Only use `decrement` when credits were genuinely consumed + * outside of normal event ingestion. + * * Orb matches the algorithm for automatic deductions for determining which credit blocks to * decrement from. In the case that the deduction leads to multiple ledger entries, the response * from this endpoint will be the final deduction. Orb also optionally allows specifying a @@ -306,10 +321,23 @@ interface LedgerServiceAsync { * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying - * the cost basis with the number of credit units added. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits - * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. + * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. A + * `decrement` entry records credits as usage and immediately recognizes revenue at the block's + * `per_unit_cost_basis`. + * + * For most credit removals, use `void` (no revenue impact) or `expiration_change` (revenue + * recognized on expiration) instead. Only use `decrement` when credits were genuinely consumed + * outside of normal event ingestion. + * * Orb matches the algorithm for automatic deductions for determining which credit blocks to * decrement from. In the case that the deduction leads to multiple ledger entries, the response * from this endpoint will be the final deduction. Orb also optionally allows specifying a @@ -415,10 +443,8 @@ interface LedgerServiceAsync { * * As usage for a customer is reported into Orb, credits may be deducted according to the * customer's plan configuration. An automated deduction of this type will result in a ledger - * entry, also with a starting and ending balance. In order to provide better tracing - * capabilities for automatic deductions, Orb always associates each automatic deduction with - * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place - * and to ensure that credits are never deducted without an associated usage event. + * entry, also with a starting and ending balance. Each day's usage for a particular price, + * invoice, and block will be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring * credit block* first in order to ensure that all credits are utilized appropriately. As an 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 671f24628..b34ef4c69 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 @@ -30,6 +30,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : LedgerServiceAsync { 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 6134a4dcf..ed0721697 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 @@ -19,6 +19,10 @@ import com.withorb.api.models.CustomerCreditTopUpListParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface TopUpServiceAsync { /** 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 5066212e6..f10916171 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 @@ -33,6 +33,10 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TopUpServiceAsync { 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 878325bf2..569208d2a 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 @@ -18,6 +18,11 @@ import com.withorb.api.models.EventBackfillRevertResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface BackfillServiceAsync { /** @@ -36,7 +41,8 @@ interface BackfillServiceAsync { * Creating the backfill enables adding or replacing past events, even those that are older than * the ingestion grace period. Performing a backfill in Orb involves 3 steps: * 1. Create the backfill, specifying its parameters. - * 2. [Ingest](ingest) usage events, referencing the backfill (query parameter `backfill_id`). + * 2. [Ingest](/api-reference/event/ingest-events) usage events, referencing the backfill (query + * parameter `backfill_id`). * 3. [Close](close-backfill) the backfill, propagating the update in past usage throughout Orb. * * Changes from a backfill are not reflected until the backfill is closed, so you won’t need to @@ -79,8 +85,7 @@ interface BackfillServiceAsync { * * The list of backfills is ordered starting from the most recently created backfill. The * response also includes [`pagination_metadata`](/api-reference/pagination), which lets the - * caller retrieve the next page of results if they exist. More information about pagination can - * be found in the [Pagination-metadata schema](pagination). + * caller retrieve the next page of results if they exist. */ fun list(): CompletableFuture = list(EventBackfillListParams.none()) 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 6ca450b93..1949b6257 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 @@ -31,6 +31,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class BackfillServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BackfillServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt index fcea10725..2910fde9c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsync.kt @@ -10,6 +10,11 @@ import com.withorb.api.models.EventVolumes import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface VolumeServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt index bdb94fcc3..2d5b37982 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/VolumeServiceAsyncImpl.kt @@ -19,6 +19,11 @@ import com.withorb.api.models.EventVolumes import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class VolumeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : VolumeServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt new file mode 100644 index 000000000..289c08001 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsync.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ExternalLicenseServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ExternalLicenseServiceAsync + + /** + * Returns usage and remaining credits for a license identified by its external license ID. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + ): CompletableFuture = + getUsage(externalLicenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + getUsage(params.toBuilder().externalLicenseId(externalLicenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams + ): CompletableFuture = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [ExternalLicenseServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ExternalLicenseServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /licenses/external_licenses/{external_license_id}/usage`, but is otherwise the same as + * [ExternalLicenseServiceAsync.getUsage]. + */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + ): CompletableFuture> = + getUsage(externalLicenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + getUsage( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams + ): CompletableFuture> = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt new file mode 100644 index 000000000..e90011845 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncImpl.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExternalLicenseServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : ExternalLicenseServiceAsync { + + private val withRawResponse: ExternalLicenseServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExternalLicenseServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): ExternalLicenseServiceAsync = + ExternalLicenseServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/external_licenses/{external_license_id}/usage + withRawResponse().getUsage(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalLicenseServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ExternalLicenseServiceAsync.WithRawResponse = + ExternalLicenseServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_licenses", params._pathParam(0), "usage") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt new file mode 100644 index 000000000..d846cfdd6 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsync.kt @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface UsageServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UsageServiceAsync + + /** + * Returns usage and remaining credits for all licenses of a given type on a subscription. + * + * Date range defaults to the current billing period if not specified. + */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams + ): CompletableFuture = + getAllUsage(params, RequestOptions.none()) + + /** @see getAllUsage */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns usage and remaining credits for a specific license over a date range. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage(licenseId: String): CompletableFuture = + getUsage(licenseId, LicenseUsageGetUsageParams.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + ): CompletableFuture = + getUsage(licenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams + ): CompletableFuture = getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + + /** A view of [UsageServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): UsageServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /licenses/usage`, but is otherwise the same as + * [UsageServiceAsync.getAllUsage]. + */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams + ): CompletableFuture> = + getAllUsage(params, RequestOptions.none()) + + /** @see getAllUsage */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}/usage`, but is otherwise the + * same as [UsageServiceAsync.getUsage]. + */ + fun getUsage( + licenseId: String + ): CompletableFuture> = + getUsage(licenseId, LicenseUsageGetUsageParams.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + ): CompletableFuture> = + getUsage(licenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams + ): CompletableFuture> = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt new file mode 100644 index 000000000..8da2e6b38 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncImpl.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepareAsync +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class UsageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UsageServiceAsync { + + private val withRawResponse: UsageServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UsageServiceAsync = + UsageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/usage + withRawResponse().getAllUsage(params, requestOptions).thenApply { it.parse() } + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /licenses/{license_id}/usage + withRawResponse().getUsage(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UsageServiceAsync.WithRawResponse = + UsageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getAllUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "usage") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getAllUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "usage") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} 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 848015d42..60e9faa52 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 @@ -11,6 +11,11 @@ import com.withorb.api.models.PlanExternalPlanIdUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface ExternalPlanIdServiceAsync { /** @@ -26,8 +31,8 @@ interface ExternalPlanIdServiceAsync { fun withOptions(modifier: Consumer): ExternalPlanIdServiceAsync /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing - * plan. + * This endpoint can be used to update the `external_plan_id`, `description`, and `metadata` of + * an existing plan. * * Other fields on a plan are currently immutable. */ 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 f793de045..207b02443 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 @@ -23,6 +23,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class ExternalPlanIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdServiceAsync { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt index 1a9b55908..d0625a60c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsync.kt @@ -14,6 +14,11 @@ import com.withorb.api.models.PlanMigrationRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface MigrationServiceAsync { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt index 0b504a915..60f5ddb1f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/MigrationServiceAsyncImpl.kt @@ -27,6 +27,11 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class MigrationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MigrationServiceAsync { 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 34498064e..d9b340534 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 @@ -11,6 +11,18 @@ import com.withorb.api.models.PriceExternalPriceIdUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface ExternalPriceIdServiceAsync { /** 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 00580b869..f72116bf6 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 @@ -23,6 +23,18 @@ import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class ExternalPriceIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdServiceAsync { 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 5dc8a9e3e..e88e7fa49 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 @@ -18,6 +18,12 @@ import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams import java.util.function.Consumer +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ interface AlertService { /** 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 daa8d5ff5..48bc0b9d4 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 @@ -30,6 +30,12 @@ import com.withorb.api.models.AlertUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, or credit + * balance and trigger webhooks when a threshold is exceeded. + * + * Alerts created through the API can be scoped to either customers or subscriptions. + */ class AlertServiceImpl internal constructor(private val clientOptions: ClientOptions) : AlertService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt index 36350b10c..80a19d174 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaService.kt @@ -14,6 +14,11 @@ import com.withorb.api.models.PlanVersion import com.withorb.api.services.blocking.beta.ExternalPlanIdService import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface BetaService { /** @@ -28,6 +33,11 @@ interface BetaService { */ fun withOptions(modifier: Consumer): BetaService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdService /** This endpoint allows the creation of a new plan version for an existing plan. */ @@ -106,6 +116,11 @@ interface BetaService { */ fun withOptions(modifier: Consumer): BetaService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdService.WithRawResponse /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt index c9916655e..756568347 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/BetaServiceImpl.kt @@ -26,6 +26,11 @@ import com.withorb.api.services.blocking.beta.ExternalPlanIdServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService { private val withRawResponse: BetaService.WithRawResponse by lazy { @@ -41,6 +46,11 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): BetaService = BetaServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdService = externalPlanId override fun createPlanVersion( @@ -81,6 +91,11 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdService.WithRawResponse = externalPlanId private val createPlanVersionHandler: Handler = 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 c634fc7fd..bab719c78 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 @@ -15,6 +15,12 @@ import com.withorb.api.models.CouponListParams import com.withorb.api.services.blocking.coupons.SubscriptionService import java.util.function.Consumer +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface CouponService { /** @@ -29,6 +35,12 @@ interface CouponService { */ fun withOptions(modifier: Consumer): CouponService + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionService /** @@ -48,8 +60,7 @@ interface CouponService { * * The list of coupons is ordered starting from the most recently created coupon. The response * also includes `pagination_metadata`, which lets the caller retrieve the next page of results - * if they exist. More information about pagination can be found in the Pagination-metadata - * schema. + * if they exist. */ fun list(): CouponListPage = list(CouponListParams.none()) @@ -140,6 +151,12 @@ interface CouponService { */ fun withOptions(modifier: Consumer): CouponService.WithRawResponse + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ fun subscriptions(): SubscriptionService.WithRawResponse /** 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 479d31180..9f5c8eca7 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 @@ -28,6 +28,12 @@ import com.withorb.api.services.blocking.coupons.SubscriptionServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class CouponServiceImpl internal constructor(private val clientOptions: ClientOptions) : CouponService { @@ -44,6 +50,12 @@ class CouponServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): CouponService = CouponServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * A coupon represents a reusable discount configuration that can be applied either as a fixed + * or percentage amount to an invoice or subscription. Coupons are activated using a redemption + * code, which applies the discount to a subscription or invoice. The duration of a coupon + * determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionService = subscriptions override fun create(params: CouponCreateParams, requestOptions: RequestOptions): Coupon = @@ -79,6 +91,12 @@ class CouponServiceImpl internal constructor(private val clientOptions: ClientOp clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * A coupon represents a reusable discount configuration that can be applied either as a + * fixed or percentage amount to an invoice or subscription. Coupons are activated using a + * redemption code, which applies the discount to a subscription or invoice. The duration of + * a coupon determines how long it remains available for use by end users. + */ override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt index 2200263f2..c1f8b4f18 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockService.kt @@ -8,10 +8,16 @@ import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponse import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditBlockService { /** @@ -98,6 +104,58 @@ interface CreditBlockService { fun delete(blockId: String, requestOptions: RequestOptions) = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + /** + * This endpoint returns the credit block and its associated purchasing invoices. + * + * If a credit block was purchased (as opposed to being manually added), this endpoint returns + * the invoices that were created to charge the customer for the credit block. For credit blocks + * with payment schedules spanning multiple periods (e.g., monthly payments over 12 months), + * multiple invoices will be returned. + * + * For credit blocks created by subscription allocation prices, this endpoint returns the + * subscription invoice containing the allocation line item that created the block. + * + * If the credit block was not purchased (e.g., manual increment), an empty invoices list is + * returned. + * + * **Note: This endpoint is currently experimental and its interface may change in future + * releases. Please contact support before building production integrations against this + * endpoint.** + */ + fun listInvoices(blockId: String): CreditBlockListInvoicesResponse = + listInvoices(blockId, CreditBlockListInvoicesParams.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditBlockListInvoicesResponse = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + ): CreditBlockListInvoicesResponse = listInvoices(blockId, params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditBlockListInvoicesResponse + + /** @see listInvoices */ + fun listInvoices(params: CreditBlockListInvoicesParams): CreditBlockListInvoicesResponse = + listInvoices(params, RequestOptions.none()) + + /** @see listInvoices */ + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): CreditBlockListInvoicesResponse = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) + /** * A view of [CreditBlockService] that provides access to raw HTTP responses for each method. */ @@ -196,5 +254,52 @@ interface CreditBlockService { @MustBeClosed fun delete(blockId: String, requestOptions: RequestOptions): HttpResponse = delete(blockId, CreditBlockDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /credit_blocks/{block_id}/invoices`, but is + * otherwise the same as [CreditBlockService.listInvoices]. + */ + @MustBeClosed + fun listInvoices(blockId: String): HttpResponseFor = + listInvoices(blockId, CreditBlockListInvoicesParams.none()) + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listInvoices(params.toBuilder().blockId(blockId).build(), requestOptions) + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + blockId: String, + params: CreditBlockListInvoicesParams = CreditBlockListInvoicesParams.none(), + ): HttpResponseFor = + listInvoices(blockId, params, RequestOptions.none()) + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + params: CreditBlockListInvoicesParams + ): HttpResponseFor = + listInvoices(params, RequestOptions.none()) + + /** @see listInvoices */ + @MustBeClosed + fun listInvoices( + blockId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listInvoices(blockId, CreditBlockListInvoicesParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt index d5cac1cc2..f65dbb26f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditBlockServiceImpl.kt @@ -18,11 +18,17 @@ import com.withorb.api.core.http.json import com.withorb.api.core.http.parseable import com.withorb.api.core.prepare import com.withorb.api.models.CreditBlockDeleteParams +import com.withorb.api.models.CreditBlockListInvoicesParams +import com.withorb.api.models.CreditBlockListInvoicesResponse import com.withorb.api.models.CreditBlockRetrieveParams import com.withorb.api.models.CreditBlockRetrieveResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditBlockServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockService { @@ -47,6 +53,13 @@ class CreditBlockServiceImpl internal constructor(private val clientOptions: Cli withRawResponse().delete(params, requestOptions) } + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): CreditBlockListInvoicesResponse = + // get /credit_blocks/{block_id}/invoices + withRawResponse().listInvoices(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CreditBlockService.WithRawResponse { @@ -113,5 +126,35 @@ class CreditBlockServiceImpl internal constructor(private val clientOptions: Cli response.use { deleteHandler.handle(it) } } } + + private val listInvoicesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listInvoices( + params: CreditBlockListInvoicesParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("blockId", params.blockId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("credit_blocks", params._pathParam(0), "invoices") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listInvoicesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } 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 f63a19914..02bf7bc9c 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 @@ -13,6 +13,10 @@ import com.withorb.api.models.CreditNoteListPage import com.withorb.api.models.CreditNoteListParams import java.util.function.Consumer +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ interface CreditNoteService { /** 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 14d2f531b..ee8d3fe41 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 @@ -25,6 +25,10 @@ import com.withorb.api.models.CreditNoteListParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ class CreditNoteServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteService { 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 957d0fb9c..05c352985 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 @@ -23,6 +23,24 @@ import com.withorb.api.services.blocking.customers.CostService import com.withorb.api.services.blocking.customers.CreditService import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CustomerService { /** @@ -37,10 +55,50 @@ interface CustomerService { */ fun withOptions(modifier: Consumer): CustomerService + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun costs(): CostService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditService + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionService /** @@ -67,8 +125,9 @@ interface CustomerService { /** * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, * `email`, `email_delivery`, `tax_id`, `auto_collection`, `metadata`, `shipping_address`, - * `billing_address`, and `additional_emails` of an existing customer. Other fields on a - * customer are currently immutable. + * `billing_address`, `additional_emails`, and `currency` of an existing customer. `currency` + * can only be set if it has not already been set on the customer. Other fields on a customer + * are currently immutable. */ fun update(customerId: String): Customer = update(customerId, CustomerUpdateParams.none()) @@ -392,10 +451,50 @@ interface CustomerService { */ fun withOptions(modifier: Consumer): CustomerService.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun costs(): CostService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun credits(): CreditService.WithRawResponse + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ fun balanceTransactions(): BalanceTransactionService.WithRawResponse /** 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 14a609ddc..1acc9ecb5 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 @@ -38,6 +38,24 @@ import com.withorb.api.services.blocking.customers.CreditServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CustomerServiceImpl internal constructor(private val clientOptions: ClientOptions) : CustomerService { @@ -58,10 +76,50 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client override fun withOptions(modifier: Consumer): CustomerService = CustomerServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun costs(): CostService = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditService = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum + * field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionService = balanceTransactions override fun create(params: CustomerCreateParams, requestOptions: RequestOptions): Customer = @@ -144,10 +202,50 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun costs(): CostService.WithRawResponse = costs + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun credits(): CreditService.WithRawResponse = credits + /** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to + * denormalize Orb ID information, you can pass in an `external_customer_id` with your own + * identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) for further + * information about how these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment + * provider solution like Stripe. Use the `payment_provider_id` and the `payment_provider` + * enum field to express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your + * account's timezone. See [Timezone localization](/essentials/timezones) for information on + * what this timezone parameter influences within Orb. + */ override fun balanceTransactions(): BalanceTransactionService.WithRawResponse = balanceTransactions 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 fab9f037b..0380e57e2 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 @@ -18,6 +18,11 @@ import com.withorb.api.services.blocking.events.BackfillService import com.withorb.api.services.blocking.events.VolumeService import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface EventService { /** @@ -32,8 +37,18 @@ interface EventService { */ fun withOptions(modifier: Consumer): EventService + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun backfills(): BackfillService + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ fun volume(): VolumeService /** @@ -399,8 +414,18 @@ interface EventService { */ fun withOptions(modifier: Consumer): EventService.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun backfills(): BackfillService.WithRawResponse + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ fun volume(): VolumeService.WithRawResponse /** 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 96d616787..51cca0969 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 @@ -31,6 +31,11 @@ import com.withorb.api.services.blocking.events.VolumeServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class EventServiceImpl internal constructor(private val clientOptions: ClientOptions) : EventService { @@ -47,8 +52,18 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): EventService = EventServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun backfills(): BackfillService = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for + * a customer. Events are the core of Orb's usage-based billing model, and are used to calculate + * the usage charges for a given billing period. + */ override fun volume(): VolumeService = volume override fun update( @@ -100,8 +115,18 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun backfills(): BackfillService.WithRawResponse = backfills + /** + * The [Event](/core-concepts#event) resource represents a usage event that has been created + * for a customer. Events are the core of Orb's usage-based billing model, and are used to + * calculate the usage charges for a given billing period. + */ override fun volume(): VolumeService.WithRawResponse = volume private val updateHandler: Handler = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt index 87b8a6fc1..1be4cc470 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt @@ -10,6 +10,13 @@ import com.withorb.api.models.InvoiceLineItemCreateParams import com.withorb.api.models.InvoiceLineItemCreateResponse import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceLineItemService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt index b6202b351..5d2f79eb3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceImpl.kt @@ -19,6 +19,13 @@ import com.withorb.api.models.InvoiceLineItemCreateParams import com.withorb.api.models.InvoiceLineItemCreateResponse import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceLineItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceLineItemService { 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 7d689c82a..4d9b1113d 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 @@ -14,6 +14,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPage import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceListSummaryPage @@ -24,6 +26,13 @@ import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams import java.util.function.Consumer +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ interface InvoiceService { /** @@ -48,13 +57,13 @@ interface InvoiceService { ): Invoice /** - * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and - * `invoice_date` properties on an invoice. If you pass null for the metadata value, it will - * clear any existing metadata for that invoice. + * This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, + * and `auto_collection` properties on an invoice. If you pass null for the metadata value, it + * will clear any existing metadata for that invoice. * - * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, and - * `invoice_date` can only be modified if the invoice is in a `draft` state. `invoice_date` can - * only be modified for non-subscription invoices. + * `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, + * `invoice_date`, and `auto_collection` can only be modified if the invoice is in a `draft` + * state. `invoice_date` can only be modified for non-subscription invoices. */ fun update(invoiceId: String): Invoice = update(invoiceId, InvoiceUpdateParams.none()) @@ -97,6 +106,10 @@ interface InvoiceService { * When fetching any `draft` invoices, this returns the last-computed invoice values for each * draft invoice, which may not always be up-to-date since Orb regularly refreshes invoices * asynchronously. + * + * If you don't need line item details, minimums, maximums, or discounts, prefer the + * [list invoices summary](/api-reference/invoice/list-invoices-summary) endpoint for better + * performance. */ fun list(): InvoiceListPage = list(InvoiceListParams.none()) @@ -215,6 +228,50 @@ interface InvoiceService { fun issue(invoiceId: String, requestOptions: RequestOptions): Invoice = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * This endpoint allows an eligible invoice to be issued manually. This is only possible with + * invoices where status is `draft`, `will_auto_issue` is false, and an `eligible_to_issue_at` + * is a time in the past. Issuing an invoice could possibly trigger side effects, some of which + * could be customer-visible (e.g. sending emails, auto-collecting payment, syncing the invoice + * to external providers, etc). + * + * This is a lighter-weight alternative to the issue invoice endpoint, returning an invoice + * summary without any line item details. + */ + fun issueSummary(invoiceId: String): InvoiceIssueSummaryResponse = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InvoiceIssueSummaryResponse = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + ): InvoiceIssueSummaryResponse = issueSummary(invoiceId, params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InvoiceIssueSummaryResponse + + /** @see issueSummary */ + fun issueSummary(params: InvoiceIssueSummaryParams): InvoiceIssueSummaryResponse = + issueSummary(params, RequestOptions.none()) + + /** @see issueSummary */ + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): InvoiceIssueSummaryResponse = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * This is a lighter-weight endpoint that returns a list of all * [`Invoice`](/core-concepts#invoice) summaries for an account in a list format. @@ -273,21 +330,23 @@ interface InvoiceService { ): Invoice /** - * 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". + * This endpoint collects payment for an invoice. By default, it uses the customer's default + * payment method. Optionally, a shared payment token (SPT) can be provided to pay using + * agent-granted credentials instead. This action can only be taken on invoices with status + * "issued". */ - fun pay(invoiceId: String): Invoice = pay(invoiceId, InvoicePayParams.none()) + fun pay(invoiceId: String, params: InvoicePayParams): Invoice = + pay(invoiceId, params, RequestOptions.none()) /** @see pay */ fun pay( invoiceId: String, - params: InvoicePayParams = InvoicePayParams.none(), + params: InvoicePayParams, 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()) + fun pay(params: InvoicePayParams): Invoice = pay(params, RequestOptions.none()) /** @see pay */ fun pay( @@ -295,13 +354,6 @@ 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 to the `void` status. This can only be * done to invoices that are in the `issued` status. @@ -563,6 +615,53 @@ interface InvoiceService { fun issue(invoiceId: String, requestOptions: RequestOptions): HttpResponseFor = issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /invoices/summary/{invoice_id}/issue`, but is + * otherwise the same as [InvoiceService.issueSummary]. + */ + @MustBeClosed + fun issueSummary(invoiceId: String): HttpResponseFor = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none()) + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + issueSummary(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + invoiceId: String, + params: InvoiceIssueSummaryParams = InvoiceIssueSummaryParams.none(), + ): HttpResponseFor = + issueSummary(invoiceId, params, RequestOptions.none()) + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + params: InvoiceIssueSummaryParams + ): HttpResponseFor = + issueSummary(params, RequestOptions.none()) + + /** @see issueSummary */ + @MustBeClosed + fun issueSummary( + invoiceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + issueSummary(invoiceId, InvoiceIssueSummaryParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices/summary`, but is otherwise the same as * [InvoiceService.listSummary]. @@ -623,24 +722,22 @@ interface InvoiceService { * same as [InvoiceService.pay]. */ @MustBeClosed - fun pay(invoiceId: String): HttpResponseFor = - pay(invoiceId, InvoicePayParams.none()) + fun pay(invoiceId: String, params: InvoicePayParams): HttpResponseFor = + pay(invoiceId, params, RequestOptions.none()) /** @see pay */ @MustBeClosed fun pay( invoiceId: String, - params: InvoicePayParams = InvoicePayParams.none(), + params: InvoicePayParams, 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()) + fun pay(params: InvoicePayParams): HttpResponseFor = + pay(params, RequestOptions.none()) /** @see pay */ @MustBeClosed @@ -649,16 +746,6 @@ 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]. 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 38ee69982..c1a7358d7 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 @@ -24,6 +24,8 @@ import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceFetchUpcomingResponse import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams +import com.withorb.api.models.InvoiceIssueSummaryResponse import com.withorb.api.models.InvoiceListPage import com.withorb.api.models.InvoiceListPageResponse import com.withorb.api.models.InvoiceListParams @@ -37,6 +39,13 @@ import com.withorb.api.models.InvoiceVoidInvoiceParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request + * for payment for a single subscription. This includes a set of line items, which correspond to + * prices in the subscription's plan and can represent fixed recurring fees or usage-based fees. + * They are generated at the end of a billing period, or as the result of an action, such as a + * cancellation. + */ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceService { @@ -84,6 +93,13 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO // post /invoices/{invoice_id}/issue withRawResponse().issue(params, requestOptions).parse() + override fun issueSummary( + params: InvoiceIssueSummaryParams, + requestOptions: RequestOptions, + ): InvoiceIssueSummaryResponse = + // post /invoices/summary/{invoice_id}/issue + withRawResponse().issueSummary(params, requestOptions).parse() + override fun listSummary( params: InvoiceListSummaryParams, requestOptions: RequestOptions, @@ -325,6 +341,37 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO } } + private val issueSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun issueSummary( + params: InvoiceIssueSummaryParams, + 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) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("invoices", "summary", params._pathParam(0), "issue") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { issueSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val listSummaryHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -404,7 +451,7 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) .addPathSegments("invoices", params._pathParam(0), "pay") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) 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 44484d718..c04fd04ff 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 @@ -15,6 +15,11 @@ import com.withorb.api.models.ItemListParams import com.withorb.api.models.ItemUpdateParams import java.util.function.Consumer +/** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for invoices + * and tax calculation purposes. + */ interface ItemService { /** 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 8378b6a89..50f3624cb 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 @@ -27,6 +27,11 @@ import com.withorb.api.models.ItemUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Item resource represents a sellable product or good. Items are associated with all line + * items, billable metrics, and prices and are used for defining external sync behavior for invoices + * and tax calculation purposes. + */ class ItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : ItemService { private val withRawResponse: ItemService.WithRawResponse by lazy { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt new file mode 100644 index 000000000..ea030c297 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseService.kt @@ -0,0 +1,338 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPage +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.blocking.licenses.ExternalLicenseService +import com.withorb.api.services.blocking.licenses.UsageService +import java.util.function.Consumer + +interface LicenseService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LicenseService + + fun externalLicenses(): ExternalLicenseService + + fun usage(): UsageService + + /** + * This endpoint is used to create a new license for a user. + * + * If a start date is provided, the license will be activated at the **start** of the specified + * date in the customer's timezone. Otherwise, the activation time will default to the **start** + * of the current day in the customer's timezone. + */ + fun create(params: LicenseCreateParams): LicenseCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseCreateResponse + + /** This endpoint is used to fetch a license given an identifier. */ + fun retrieve(licenseId: String): LicenseRetrieveResponse = + retrieve(licenseId, LicenseRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveResponse = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + ): LicenseRetrieveResponse = retrieve(licenseId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: LicenseRetrieveParams): LicenseRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(licenseId: String, requestOptions: RequestOptions): LicenseRetrieveResponse = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** This endpoint returns a list of all licenses for a subscription. */ + fun list(params: LicenseListParams): LicenseListPage = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseListPage + + /** + * This endpoint is used to deactivate an existing license. + * + * If an end date is provided, the license will be deactivated at the **start** of the specified + * date in the customer's timezone. Otherwise, the deactivation time will default to the **end** + * of the current day in the customer's timezone. + */ + fun deactivate(licenseId: String): LicenseDeactivateResponse = + deactivate(licenseId, LicenseDeactivateParams.none()) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseDeactivateResponse = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + ): LicenseDeactivateResponse = deactivate(licenseId, params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseDeactivateResponse + + /** @see deactivate */ + fun deactivate(params: LicenseDeactivateParams): LicenseDeactivateResponse = + deactivate(params, RequestOptions.none()) + + /** @see deactivate */ + fun deactivate(licenseId: String, requestOptions: RequestOptions): LicenseDeactivateResponse = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** This endpoint is used to fetch a license given an external license identifier. */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + ): LicenseRetrieveByExternalIdResponse = + retrieveByExternalId(externalLicenseId, params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveByExternalIdResponse = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams + ): LicenseRetrieveByExternalIdResponse = retrieveByExternalId(params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseRetrieveByExternalIdResponse + + /** A view of [LicenseService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LicenseService.WithRawResponse + + fun externalLicenses(): ExternalLicenseService.WithRawResponse + + fun usage(): UsageService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /licenses`, but is otherwise the same as + * [LicenseService.create]. + */ + @MustBeClosed + fun create(params: LicenseCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}`, but is otherwise the same + * as [LicenseService.retrieve]. + */ + @MustBeClosed + fun retrieve(licenseId: String): HttpResponseFor = + retrieve(licenseId, LicenseRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseId: String, + params: LicenseRetrieveParams = LicenseRetrieveParams.none(), + ): HttpResponseFor = + retrieve(licenseId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: LicenseRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(licenseId, LicenseRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /licenses`, but is otherwise the same as + * [LicenseService.list]. + */ + @MustBeClosed + fun list(params: LicenseListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: LicenseListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /licenses/{license_id}/deactivate`, but is + * otherwise the same as [LicenseService.deactivate]. + */ + @MustBeClosed + fun deactivate(licenseId: String): HttpResponseFor = + deactivate(licenseId, LicenseDeactivateParams.none()) + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + deactivate(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + licenseId: String, + params: LicenseDeactivateParams = LicenseDeactivateParams.none(), + ): HttpResponseFor = + deactivate(licenseId, params, RequestOptions.none()) + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + params: LicenseDeactivateParams + ): HttpResponseFor = deactivate(params, RequestOptions.none()) + + /** @see deactivate */ + @MustBeClosed + fun deactivate( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + deactivate(licenseId, LicenseDeactivateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get + * /licenses/external_license_id/{external_license_id}`, but is otherwise the same as + * [LicenseService.retrieveByExternalId]. + */ + @MustBeClosed + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + ): HttpResponseFor = + retrieveByExternalId(externalLicenseId, params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + @MustBeClosed + fun retrieveByExternalId( + externalLicenseId: String, + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveByExternalId( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see retrieveByExternalId */ + @MustBeClosed + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams + ): HttpResponseFor = + retrieveByExternalId(params, RequestOptions.none()) + + /** @see retrieveByExternalId */ + @MustBeClosed + fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt new file mode 100644 index 000000000..e3b548f3d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseServiceImpl.kt @@ -0,0 +1,269 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseCreateResponse +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseDeactivateResponse +import com.withorb.api.models.LicenseListPage +import com.withorb.api.models.LicenseListPageResponse +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import com.withorb.api.models.LicenseRetrieveByExternalIdResponse +import com.withorb.api.models.LicenseRetrieveParams +import com.withorb.api.models.LicenseRetrieveResponse +import com.withorb.api.services.blocking.licenses.ExternalLicenseService +import com.withorb.api.services.blocking.licenses.ExternalLicenseServiceImpl +import com.withorb.api.services.blocking.licenses.UsageService +import com.withorb.api.services.blocking.licenses.UsageServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class LicenseServiceImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseService { + + private val withRawResponse: LicenseService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val externalLicenses: ExternalLicenseService by lazy { + ExternalLicenseServiceImpl(clientOptions) + } + + private val usage: UsageService by lazy { UsageServiceImpl(clientOptions) } + + override fun withRawResponse(): LicenseService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LicenseService = + LicenseServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun externalLicenses(): ExternalLicenseService = externalLicenses + + override fun usage(): UsageService = usage + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): LicenseCreateResponse = + // post /licenses + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): LicenseRetrieveResponse = + // get /licenses/{license_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list(params: LicenseListParams, requestOptions: RequestOptions): LicenseListPage = + // get /licenses + withRawResponse().list(params, requestOptions).parse() + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): LicenseDeactivateResponse = + // post /licenses/{license_id}/deactivate + withRawResponse().deactivate(params, requestOptions).parse() + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): LicenseRetrieveByExternalIdResponse = + // get /licenses/external_license_id/{external_license_id} + withRawResponse().retrieveByExternalId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val externalLicenses: ExternalLicenseService.WithRawResponse by lazy { + ExternalLicenseServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val usage: UsageService.WithRawResponse by lazy { + UsageServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): LicenseService.WithRawResponse = + LicenseServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun externalLicenses(): ExternalLicenseService.WithRawResponse = externalLicenses + + override fun usage(): UsageService.WithRawResponse = usage + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseListPage.builder() + .service(LicenseServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val deactivateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun deactivate( + params: LicenseDeactivateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "deactivate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deactivateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveByExternalId( + params: LicenseRetrieveByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_license_id", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt new file mode 100644 index 000000000..108c63fd2 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeService.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPage +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse +import java.util.function.Consumer + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +interface LicenseTypeService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LicenseTypeService + + /** + * This endpoint is used to create a new license type. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun create(params: LicenseTypeCreateParams): LicenseTypeCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeCreateResponse + + /** + * This endpoint returns a license type identified by its license_type_id. + * + * Use this endpoint to retrieve details about a specific license type, including its name and + * grouping key. + */ + fun retrieve(licenseTypeId: String): LicenseTypeRetrieveResponse = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeRetrieveResponse = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + ): LicenseTypeRetrieveResponse = retrieve(licenseTypeId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: LicenseTypeRetrieveParams): LicenseTypeRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): LicenseTypeRetrieveResponse = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * This endpoint returns a list of all license types configured for the account, ordered in + * ascending order by creation time. + * + * License types are used to group licenses and define billing behavior. Each license type has a + * name and a grouping key that determines how metrics are aggregated for billing purposes. + */ + fun list(): LicenseTypeListPage = list(LicenseTypeListParams.none()) + + /** @see list */ + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseTypeListPage + + /** @see list */ + fun list(params: LicenseTypeListParams = LicenseTypeListParams.none()): LicenseTypeListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): LicenseTypeListPage = + list(LicenseTypeListParams.none(), requestOptions) + + /** + * A view of [LicenseTypeService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): LicenseTypeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /license_types`, but is otherwise the same as + * [LicenseTypeService.create]. + */ + @MustBeClosed + fun create(params: LicenseTypeCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /license_types/{license_type_id}`, but is otherwise + * the same as [LicenseTypeService.retrieve]. + */ + @MustBeClosed + fun retrieve(licenseTypeId: String): HttpResponseFor = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().licenseTypeId(licenseTypeId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseTypeId: String, + params: LicenseTypeRetrieveParams = LicenseTypeRetrieveParams.none(), + ): HttpResponseFor = + retrieve(licenseTypeId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: LicenseTypeRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + licenseTypeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(licenseTypeId, LicenseTypeRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /license_types`, but is otherwise the same as + * [LicenseTypeService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(LicenseTypeListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: LicenseTypeListParams = LicenseTypeListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(LicenseTypeListParams.none(), requestOptions) + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt new file mode 100644 index 000000000..0d5e35c45 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceImpl.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.json +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseTypeCreateParams +import com.withorb.api.models.LicenseTypeCreateResponse +import com.withorb.api.models.LicenseTypeListPage +import com.withorb.api.models.LicenseTypeListPageResponse +import com.withorb.api.models.LicenseTypeListParams +import com.withorb.api.models.LicenseTypeRetrieveParams +import com.withorb.api.models.LicenseTypeRetrieveResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** + * The LicenseType resource represents a type of license that can be assigned to users. License + * types are used during billing by grouping metrics on the configured grouping key. + */ +class LicenseTypeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeService { + + private val withRawResponse: LicenseTypeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LicenseTypeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LicenseTypeService = + LicenseTypeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): LicenseTypeCreateResponse = + // post /license_types + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): LicenseTypeRetrieveResponse = + // get /license_types/{license_type_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): LicenseTypeListPage = + // get /license_types + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LicenseTypeService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): LicenseTypeService.WithRawResponse = + LicenseTypeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LicenseTypeCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: LicenseTypeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseTypeId", params.licenseTypeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: LicenseTypeListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("license_types") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + LicenseTypeListPage.builder() + .service(LicenseTypeServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} 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 27b8d7532..c041139c2 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 @@ -14,6 +14,10 @@ import com.withorb.api.models.MetricListParams import com.withorb.api.models.MetricUpdateParams import java.util.function.Consumer +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ interface MetricService { /** @@ -74,9 +78,8 @@ interface MetricService { 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 - * item. + * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about + * the metrics including its name, description, and item. */ fun list(): MetricListPage = list(MetricListParams.none()) @@ -95,8 +98,9 @@ interface MetricService { list(MetricListParams.none(), requestOptions) /** - * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about - * the metrics including its name, description, and item. + * 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 + * item. */ fun fetch(metricId: String): BillableMetric = fetch(metricId, MetricFetchParams.none()) 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 91855682b..2dbcc1477 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 @@ -26,6 +26,10 @@ import com.withorb.api.models.MetricUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Metric resource represents a calculation of a quantity based on events. Metrics are defined + * by the query that transforms raw usage events into meaningful values for your customers. + */ class MetricServiceImpl internal constructor(private val clientOptions: ClientOptions) : MetricService { 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 8bbdb710b..984a9b570 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 @@ -16,6 +16,11 @@ import com.withorb.api.services.blocking.plans.ExternalPlanIdService import com.withorb.api.services.blocking.plans.MigrationService import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface PlanService { /** @@ -30,8 +35,18 @@ interface PlanService { */ fun withOptions(modifier: Consumer): PlanService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdService + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ fun migrations(): MigrationService /** This endpoint allows creation of plans including their prices. */ @@ -44,8 +59,8 @@ interface PlanService { ): Plan /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing - * plan. + * This endpoint can be used to update the `external_plan_id`, `description`, and `metadata` of + * an existing plan. * * Other fields on a plan are currently immutable. */ @@ -146,8 +161,18 @@ interface PlanService { */ fun withOptions(modifier: Consumer): PlanService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun externalPlanId(): ExternalPlanIdService.WithRawResponse + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ fun migrations(): MigrationService.WithRawResponse /** 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 c279f8f85..347869694 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 @@ -30,6 +30,11 @@ import com.withorb.api.services.blocking.plans.MigrationServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class PlanServiceImpl internal constructor(private val clientOptions: ClientOptions) : PlanService { private val withRawResponse: PlanService.WithRawResponse by lazy { @@ -47,8 +52,18 @@ class PlanServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): PlanService = PlanServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdService = externalPlanId + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed + * to by a customer. Plans define the billing behavior of the subscription. You can see more + * about how to configure prices in the [Price resource](/reference/price). + */ override fun migrations(): MigrationService = migrations override fun create(params: PlanCreateParams, requestOptions: RequestOptions): Plan = @@ -88,8 +103,18 @@ class PlanServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun externalPlanId(): ExternalPlanIdService.WithRawResponse = externalPlanId + /** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be + * subscribed to by a customer. Plans define the billing behavior of the subscription. You + * can see more about how to configure prices in the [Price resource](/reference/price). + */ override fun migrations(): MigrationService.WithRawResponse = migrations private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) 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 15877052b..c51460287 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 @@ -6,6 +6,32 @@ import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.ClientOptions import com.withorb.api.core.RequestOptions import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.NewFloatingBulkPrice +import com.withorb.api.models.NewFloatingBulkWithProrationPrice +import com.withorb.api.models.NewFloatingCumulativeGroupedBulkPrice +import com.withorb.api.models.NewFloatingGroupedAllocationPrice +import com.withorb.api.models.NewFloatingGroupedTieredPackagePrice +import com.withorb.api.models.NewFloatingGroupedTieredPrice +import com.withorb.api.models.NewFloatingGroupedWithMeteredMinimumPrice +import com.withorb.api.models.NewFloatingGroupedWithProratedMinimumPrice +import com.withorb.api.models.NewFloatingMatrixPrice +import com.withorb.api.models.NewFloatingMatrixWithAllocationPrice +import com.withorb.api.models.NewFloatingMatrixWithDisplayNamePrice +import com.withorb.api.models.NewFloatingMaxGroupTieredPackagePrice +import com.withorb.api.models.NewFloatingMinimumCompositePrice +import com.withorb.api.models.NewFloatingPackagePrice +import com.withorb.api.models.NewFloatingPackageWithAllocationPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithTieredPricingPrice +import com.withorb.api.models.NewFloatingScalableMatrixWithUnitPricingPrice +import com.withorb.api.models.NewFloatingThresholdTotalAmountPrice +import com.withorb.api.models.NewFloatingTieredPackagePrice +import com.withorb.api.models.NewFloatingTieredPackageWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredPrice +import com.withorb.api.models.NewFloatingTieredWithMinimumPrice +import com.withorb.api.models.NewFloatingTieredWithProrationPrice +import com.withorb.api.models.NewFloatingUnitPrice +import com.withorb.api.models.NewFloatingUnitWithPercentPrice +import com.withorb.api.models.NewFloatingUnitWithProrationPrice import com.withorb.api.models.Price import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams @@ -21,6 +47,18 @@ import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.blocking.prices.ExternalPriceIdService import java.util.function.Consumer +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface PriceService { /** @@ -35,6 +73,18 @@ interface PriceService { */ fun withOptions(modifier: Consumer): PriceService + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdService /** @@ -57,6 +107,410 @@ interface PriceService { requestOptions: RequestOptions = RequestOptions.none(), ): Price + /** @see create */ + fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + fun create(body: PriceCreateParams.Body): Price = create(body, RequestOptions.none()) + + /** @see create */ + fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + fun create(unit: NewFloatingUnitPrice): Price = create(unit, RequestOptions.none()) + + /** @see create */ + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + fun create(tiered: NewFloatingTieredPrice): Price = create(tiered, RequestOptions.none()) + + /** @see create */ + fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + fun create(bulk: NewFloatingBulkPrice): Price = create(bulk, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + fun create(bulkWithFilters: PriceCreateParams.Body.BulkWithFilters): Price = + create(bulkWithFilters, RequestOptions.none()) + + /** @see create */ + fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + fun create(package_: NewFloatingPackagePrice): Price = create(package_, RequestOptions.none()) + + /** @see create */ + fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + fun create(matrix: NewFloatingMatrixPrice): Price = create(matrix, RequestOptions.none()) + + /** @see create */ + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), requestOptions) + + /** @see create */ + fun create(thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice): Price = + create(thresholdTotalAmount, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + fun create(tieredPackage: NewFloatingTieredPackagePrice): Price = + create(tieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + fun create(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): Price = + create(tieredWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + fun create(groupedTiered: NewFloatingGroupedTieredPrice): Price = + create(groupedTiered, RequestOptions.none()) + + /** @see create */ + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + fun create(tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice): Price = + create(tieredPackageWithMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + fun create(packageWithAllocation: NewFloatingPackageWithAllocationPrice): Price = + create(packageWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + fun create(unitWithPercent: NewFloatingUnitWithPercentPrice): Price = + create(unitWithPercent, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), requestOptions) + + /** @see create */ + fun create(matrixWithAllocation: NewFloatingMatrixWithAllocationPrice): Price = + create(matrixWithAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithThresholdDiscounts: PriceCreateParams.Body.MatrixWithThresholdDiscounts, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts), + requestOptions, + ) + + /** @see create */ + fun create( + matrixWithThresholdDiscounts: PriceCreateParams.Body.MatrixWithThresholdDiscounts + ): Price = create(matrixWithThresholdDiscounts, RequestOptions.none()) + + /** @see create */ + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), requestOptions) + + /** @see create */ + fun create(tieredWithProration: NewFloatingTieredWithProrationPrice): Price = + create(tieredWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + fun create(unitWithProration: NewFloatingUnitWithProrationPrice): Price = + create(unitWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + fun create(groupedAllocation: NewFloatingGroupedAllocationPrice): Price = + create(groupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + fun create(bulkWithProration: NewFloatingBulkWithProrationPrice): Price = + create(bulkWithProration, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + fun create(groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice): Price = + create(groupedWithProratedMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + fun create(groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice): Price = + create(groupedWithMeteredMinimum, RequestOptions.none()) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds + ): Price = create(groupedWithMinMaxThresholds, RequestOptions.none()) + + /** @see create */ + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + fun create(matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice): Price = + create(matrixWithDisplayName, RequestOptions.none()) + + /** @see create */ + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), requestOptions) + + /** @see create */ + fun create(groupedTieredPackage: NewFloatingGroupedTieredPackagePrice): Price = + create(groupedTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + fun create(maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice): Price = + create(maxGroupTieredPackage, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice + ): Price = create(scalableMatrixWithUnitPricing, RequestOptions.none()) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice + ): Price = create(scalableMatrixWithTieredPricing, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + fun create(cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice): Price = + create(cumulativeGroupedBulk, RequestOptions.none()) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation + ): Price = create(cumulativeGroupedAllocation, RequestOptions.none()) + + /** @see create */ + fun create( + dailyCreditAllowance: PriceCreateParams.Body.DailyCreditAllowance, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = + create(PriceCreateParams.Body.ofDailyCreditAllowance(dailyCreditAllowance), requestOptions) + + /** @see create */ + fun create(dailyCreditAllowance: PriceCreateParams.Body.DailyCreditAllowance): Price = + create(dailyCreditAllowance, RequestOptions.none()) + + /** @see create */ + fun create( + meteredAllowance: PriceCreateParams.Body.MeteredAllowance, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofMeteredAllowance(meteredAllowance), requestOptions) + + /** @see create */ + fun create(meteredAllowance: PriceCreateParams.Body.MeteredAllowance): Price = + create(meteredAllowance, RequestOptions.none()) + + /** @see create */ + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + fun create(minimumComposite: NewFloatingMinimumCompositePrice): Price = + create(minimumComposite, RequestOptions.none()) + + /** @see create */ + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + fun create(percent: PriceCreateParams.Body.Percent): Price = + create(percent, RequestOptions.none()) + + /** @see create */ + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + + /** @see create */ + fun create(eventOutput: PriceCreateParams.Body.EventOutput): Price = + create(eventOutput, RequestOptions.none()) + /** * 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. @@ -248,6 +702,18 @@ interface PriceService { */ fun withOptions(modifier: Consumer): PriceService.WithRawResponse + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ fun externalPriceId(): ExternalPriceIdService.WithRawResponse /** @@ -265,6 +731,531 @@ interface PriceService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see create */ + @MustBeClosed + fun create( + body: PriceCreateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.builder().body(body).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(body: PriceCreateParams.Body): HttpResponseFor = + create(body, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + unit: NewFloatingUnitPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofUnit(unit), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(unit: NewFloatingUnitPrice): HttpResponseFor = + create(unit, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tiered: NewFloatingTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofTiered(tiered), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(tiered: NewFloatingTieredPrice): HttpResponseFor = + create(tiered, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + bulk: NewFloatingBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofBulk(bulk), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(bulk: NewFloatingBulkPrice): HttpResponseFor = + create(bulk, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofBulkWithFilters(bulkWithFilters), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + bulkWithFilters: PriceCreateParams.Body.BulkWithFilters + ): HttpResponseFor = create(bulkWithFilters, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + package_: NewFloatingPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofPackage(package_), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(package_: NewFloatingPackagePrice): HttpResponseFor = + create(package_, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + matrix: NewFloatingMatrixPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(PriceCreateParams.Body.ofMatrix(matrix), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(matrix: NewFloatingMatrixPrice): HttpResponseFor = + create(matrix, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofThresholdTotalAmount(thresholdTotalAmount), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + thresholdTotalAmount: NewFloatingThresholdTotalAmountPrice + ): HttpResponseFor = create(thresholdTotalAmount, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tieredPackage: NewFloatingTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofTieredPackage(tieredPackage), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(tieredPackage: NewFloatingTieredPackagePrice): HttpResponseFor = + create(tieredPackage, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tieredWithMinimum: NewFloatingTieredWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofTieredWithMinimum(tieredWithMinimum), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(tieredWithMinimum: NewFloatingTieredWithMinimumPrice): HttpResponseFor = + create(tieredWithMinimum, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedTiered: NewFloatingGroupedTieredPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofGroupedTiered(groupedTiered), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(groupedTiered: NewFloatingGroupedTieredPrice): HttpResponseFor = + create(groupedTiered, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + tieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice + ): HttpResponseFor = create(tieredPackageWithMinimum, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofPackageWithAllocation(packageWithAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + packageWithAllocation: NewFloatingPackageWithAllocationPrice + ): HttpResponseFor = create(packageWithAllocation, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + unitWithPercent: NewFloatingUnitWithPercentPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofUnitWithPercent(unitWithPercent), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(unitWithPercent: NewFloatingUnitWithPercentPrice): HttpResponseFor = + create(unitWithPercent, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMatrixWithAllocation(matrixWithAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithAllocation: NewFloatingMatrixWithAllocationPrice + ): HttpResponseFor = create(matrixWithAllocation, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithThresholdDiscounts: PriceCreateParams.Body.MatrixWithThresholdDiscounts, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithThresholdDiscounts: PriceCreateParams.Body.MatrixWithThresholdDiscounts + ): HttpResponseFor = create(matrixWithThresholdDiscounts, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofTieredWithProration(tieredWithProration), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + tieredWithProration: NewFloatingTieredWithProrationPrice + ): HttpResponseFor = create(tieredWithProration, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + unitWithProration: NewFloatingUnitWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofUnitWithProration(unitWithProration), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(unitWithProration: NewFloatingUnitWithProrationPrice): HttpResponseFor = + create(unitWithProration, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedAllocation: NewFloatingGroupedAllocationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofGroupedAllocation(groupedAllocation), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(groupedAllocation: NewFloatingGroupedAllocationPrice): HttpResponseFor = + create(groupedAllocation, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + bulkWithProration: NewFloatingBulkWithProrationPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofBulkWithProration(bulkWithProration), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(bulkWithProration: NewFloatingBulkWithProrationPrice): HttpResponseFor = + create(bulkWithProration, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithProratedMinimum: NewFloatingGroupedWithProratedMinimumPrice + ): HttpResponseFor = create(groupedWithProratedMinimum, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice + ): HttpResponseFor = create(groupedWithMeteredMinimum, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedWithMinMaxThresholds: PriceCreateParams.Body.GroupedWithMinMaxThresholds + ): HttpResponseFor = create(groupedWithMinMaxThresholds, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMatrixWithDisplayName(matrixWithDisplayName), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + matrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + ): HttpResponseFor = create(matrixWithDisplayName, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofGroupedTieredPackage(groupedTieredPackage), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + groupedTieredPackage: NewFloatingGroupedTieredPackagePrice + ): HttpResponseFor = create(groupedTieredPackage, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofMaxGroupTieredPackage(maxGroupTieredPackage), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + maxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + ): HttpResponseFor = create(maxGroupTieredPackage, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing + ), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithUnitPricing: NewFloatingScalableMatrixWithUnitPricingPrice + ): HttpResponseFor = create(scalableMatrixWithUnitPricing, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing + ), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + scalableMatrixWithTieredPricing: NewFloatingScalableMatrixWithTieredPricingPrice + ): HttpResponseFor = create(scalableMatrixWithTieredPricing, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice + ): HttpResponseFor = create(cumulativeGroupedBulk, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + cumulativeGroupedAllocation: PriceCreateParams.Body.CumulativeGroupedAllocation + ): HttpResponseFor = create(cumulativeGroupedAllocation, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + dailyCreditAllowance: PriceCreateParams.Body.DailyCreditAllowance, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + PriceCreateParams.Body.ofDailyCreditAllowance(dailyCreditAllowance), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + dailyCreditAllowance: PriceCreateParams.Body.DailyCreditAllowance + ): HttpResponseFor = create(dailyCreditAllowance, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + meteredAllowance: PriceCreateParams.Body.MeteredAllowance, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofMeteredAllowance(meteredAllowance), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + meteredAllowance: PriceCreateParams.Body.MeteredAllowance + ): HttpResponseFor = create(meteredAllowance, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + minimumComposite: NewFloatingMinimumCompositePrice, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofMinimumComposite(minimumComposite), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(minimumComposite: NewFloatingMinimumCompositePrice): HttpResponseFor = + create(minimumComposite, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + percent: PriceCreateParams.Body.Percent, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofPercent(percent), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(percent: PriceCreateParams.Body.Percent): HttpResponseFor = + create(percent, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + eventOutput: PriceCreateParams.Body.EventOutput, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(PriceCreateParams.Body.ofEventOutput(eventOutput), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(eventOutput: PriceCreateParams.Body.EventOutput): HttpResponseFor = + create(eventOutput, RequestOptions.none()) + /** * Returns a raw HTTP response for `put /prices/{price_id}`, but is otherwise the same as * [PriceService.update]. 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 f880d0f39..47636a3f0 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 @@ -34,6 +34,18 @@ import com.withorb.api.services.blocking.prices.ExternalPriceIdServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class PriceServiceImpl internal constructor(private val clientOptions: ClientOptions) : PriceService { @@ -50,6 +62,18 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): PriceService = PriceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdService = externalPriceId override fun create(params: PriceCreateParams, requestOptions: RequestOptions): Price = @@ -106,6 +130,18 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ override fun externalPriceId(): ExternalPriceIdService.WithRawResponse = externalPriceId private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) 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 e50436e44..5a0cf26b1 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 @@ -476,9 +476,9 @@ interface SubscriptionService { * units rather than a currency). * * The semantics of this endpoint exactly mirror those of - * [fetching a customer's costs](fetch-customer-costs). Use this endpoint to limit your analysis - * 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). + * [fetching a customer's costs](/api-reference/customer/fetch-customer-costs). Use this + * endpoint to limit your analysis 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): SubscriptionFetchCostsResponse = fetchCosts(subscriptionId, SubscriptionFetchCostsParams.none()) @@ -1108,6 +1108,12 @@ interface SubscriptionService { * To be eligible, the subscription must currently be active and have a future cancellation. * This operation will turn on auto-renew, ensuring that the subscription does not end at the * currently scheduled cancellation time. + * + * Note: uncancellation is a lossy operation. Price intervals that were cut short by the + * cancellation are extended to infinity (original end dates are lost), and future intervals or + * phases scheduled after the cancellation time are permanently deleted. For complex + * subscriptions with phases or scheduled plan changes, consider creating a new plan change + * instead of uncancelling. */ fun unscheduleCancellation(subscriptionId: String): MutatedSubscription = unscheduleCancellation(subscriptionId, SubscriptionUnscheduleCancellationParams.none()) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt index b4c642cef..75cd84e63 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdService.kt @@ -13,6 +13,11 @@ import com.withorb.api.models.Plan import com.withorb.api.models.PlanVersion import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface ExternalPlanIdService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt index c6c1c9f1d..90ac53eae 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceImpl.kt @@ -24,6 +24,11 @@ import com.withorb.api.models.PlanVersion import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdService { 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 3fbca7cee..0027ee274 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 @@ -10,6 +10,12 @@ import com.withorb.api.models.CouponSubscriptionListPage import com.withorb.api.models.CouponSubscriptionListParams import java.util.function.Consumer +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ interface SubscriptionService { /** 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 7b05ab124..086f4f253 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 @@ -21,6 +21,12 @@ import com.withorb.api.models.Subscriptions import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A coupon represents a reusable discount configuration that can be applied either as a fixed or + * percentage amount to an invoice or subscription. Coupons are activated using a redemption code, + * which applies the discount to a subscription or invoice. The duration of a coupon determines how + * long it remains available for use by end users. + */ class SubscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionService { 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 cd88ed57e..454c48523 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 @@ -12,6 +12,24 @@ import com.withorb.api.models.CustomerBalanceTransactionListPage import com.withorb.api.models.CustomerBalanceTransactionListParams import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface BalanceTransactionService { /** 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 581300c3a..40842c9fb 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 @@ -24,6 +24,24 @@ import com.withorb.api.models.CustomerBalanceTransactionListParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class BalanceTransactionServiceImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionService { 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 bab452f94..c673e8d59 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 @@ -12,6 +12,24 @@ import com.withorb.api.models.CustomerCostListParams import com.withorb.api.models.CustomerCostListResponse import java.util.function.Consumer +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ interface CostService { /** 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 9eedcf79f..18b17721f 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 @@ -22,6 +22,24 @@ import com.withorb.api.models.CustomerCostListResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * A customer is a buyer of your products, and the other party to the billing relationship. + * + * In Orb, customers are assigned system generated identifiers automatically, but it's often + * desirable to have these match existing identifiers in your system. To avoid having to denormalize + * Orb ID information, you can pass in an `external_customer_id` with your own identifier. See + * [Customer ID Aliases](/events-and-metrics/customer-aliases) for further information about how + * these aliases work in Orb. + * + * In addition to having an identifier in your system, a customer may exist in a payment provider + * solution like Stripe. Use the `payment_provider_id` and the `payment_provider` enum field to + * express this mapping. + * + * A customer also has a timezone (from the standard + * [IANA timezone database](https://www.iana.org/time-zones)), which defaults to your account's + * timezone. See [Timezone localization](/essentials/timezones) for information on what this + * timezone parameter influences within Orb. + */ class CostServiceImpl internal constructor(private val clientOptions: ClientOptions) : CostService { private val withRawResponse: CostService.WithRawResponse by lazy { 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 3b33b59ad..4af1d232b 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 @@ -14,6 +14,10 @@ import com.withorb.api.services.blocking.customers.credits.LedgerService import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface CreditService { /** @@ -28,8 +32,16 @@ interface CreditService { */ fun withOptions(modifier: Consumer): CreditService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerService + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpService /** @@ -40,6 +52,11 @@ interface CreditService { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun list(customerId: String): CustomerCreditListPage = list(customerId, CustomerCreditListParams.none()) @@ -80,6 +97,11 @@ interface CreditService { * * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. + * + * Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, + * `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. This + * filters on when the credit block becomes effective, which may differ from creation time for + * backdated credits. */ fun listByExternalId(externalCustomerId: String): CustomerCreditListByExternalIdPage = listByExternalId(externalCustomerId, CustomerCreditListByExternalIdParams.none()) @@ -134,8 +156,16 @@ interface CreditService { */ fun withOptions(modifier: Consumer): CreditService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun ledger(): LedgerService.WithRawResponse + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ fun topUps(): TopUpService.WithRawResponse /** 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 ae2dfe22c..99bb263ad 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 @@ -28,6 +28,10 @@ import com.withorb.api.services.blocking.customers.credits.TopUpServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class CreditServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditService { @@ -44,8 +48,16 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): CreditService = CreditServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerService = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpService = topUps override fun list( @@ -83,8 +95,16 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp clientOptions.toBuilder().apply(modifier::accept).build() ) + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun ledger(): LedgerService.WithRawResponse = ledger + /** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits + * within Orb. + */ override fun topUps(): TopUpService.WithRawResponse = topUps private val listHandler: Handler = 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 c72bb7243..ce82abe69 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 @@ -16,6 +16,10 @@ import com.withorb.api.models.CustomerCreditLedgerListPage import com.withorb.api.models.CustomerCreditLedgerListParams import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface LedgerService { /** @@ -54,10 +58,8 @@ interface LedgerService { * * As usage for a customer is reported into Orb, credits may be deducted according to the * customer's plan configuration. An automated deduction of this type will result in a ledger - * entry, also with a starting and ending balance. In order to provide better tracing - * capabilities for automatic deductions, Orb always associates each automatic deduction with - * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place - * and to ensure that credits are never deducted without an associated usage event. + * entry, also with a starting and ending balance. Each day's usage for a particular price, + * invoice, and block will be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring * credit block* first in order to ensure that all credits are utilized appropriately. As an @@ -176,10 +178,23 @@ interface LedgerService { * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying - * the cost basis with the number of credit units added. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits - * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. + * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. A + * `decrement` entry records credits as usage and immediately recognizes revenue at the block's + * `per_unit_cost_basis`. + * + * For most credit removals, use `void` (no revenue impact) or `expiration_change` (revenue + * recognized on expiration) instead. Only use `decrement` when credits were genuinely consumed + * outside of normal event ingestion. + * * Orb matches the algorithm for automatic deductions for determining which credit blocks to * decrement from. In the case that the deduction leads to multiple ledger entries, the response * from this endpoint will be the final deduction. Orb also optionally allows specifying a @@ -300,10 +315,23 @@ interface LedgerService { * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying - * the cost basis with the number of credit units added. + * the cost basis with the number of credit units added. If you invoice or handle payment of + * credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in the + * `invoice_settings` to `true` to prevent duplicate invoicing effects. + * * if `per_unit_cost_basis` is greater than zero, an invoice will be generated and + * `invoice_settings` must be included + * * if `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is required + * to determine the due date * * ## Deducting Credits - * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. + * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. A + * `decrement` entry records credits as usage and immediately recognizes revenue at the block's + * `per_unit_cost_basis`. + * + * For most credit removals, use `void` (no revenue impact) or `expiration_change` (revenue + * recognized on expiration) instead. Only use `decrement` when credits were genuinely consumed + * outside of normal event ingestion. + * * Orb matches the algorithm for automatic deductions for determining which credit blocks to * decrement from. In the case that the deduction leads to multiple ledger entries, the response * from this endpoint will be the final deduction. Orb also optionally allows specifying a @@ -409,10 +437,8 @@ interface LedgerService { * * As usage for a customer is reported into Orb, credits may be deducted according to the * customer's plan configuration. An automated deduction of this type will result in a ledger - * entry, also with a starting and ending balance. In order to provide better tracing - * capabilities for automatic deductions, Orb always associates each automatic deduction with - * the `event_id` at the time of ingestion, used to pinpoint _why_ credit deduction took place - * and to ensure that credits are never deducted without an associated usage event. + * entry, also with a starting and ending balance. Each day's usage for a particular price, + * invoice, and block will be grouped into a single entry. * * By default, Orb uses an algorithm that automatically deducts from the *soonest expiring * credit block* first in order to ensure that all credits are utilized appropriately. As an 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 d1e4410ff..c227918a0 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 @@ -29,6 +29,10 @@ import com.withorb.api.models.CustomerCreditLedgerListParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class LedgerServiceImpl internal constructor(private val clientOptions: ClientOptions) : LedgerService { 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 429b2af1f..83b77e7cf 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 @@ -19,6 +19,10 @@ import com.withorb.api.models.CustomerCreditTopUpListPage import com.withorb.api.models.CustomerCreditTopUpListParams import java.util.function.Consumer +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ interface TopUpService { /** 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 80592386d..a9965b21c 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 @@ -32,6 +32,10 @@ import com.withorb.api.models.CustomerCreditTopUpListParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within + * Orb. + */ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOptions) : TopUpService { 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 954b6375c..399d32850 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 @@ -18,6 +18,11 @@ import com.withorb.api.models.EventBackfillRevertParams import com.withorb.api.models.EventBackfillRevertResponse import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface BackfillService { /** @@ -36,7 +41,8 @@ interface BackfillService { * Creating the backfill enables adding or replacing past events, even those that are older than * the ingestion grace period. Performing a backfill in Orb involves 3 steps: * 1. Create the backfill, specifying its parameters. - * 2. [Ingest](ingest) usage events, referencing the backfill (query parameter `backfill_id`). + * 2. [Ingest](/api-reference/event/ingest-events) usage events, referencing the backfill (query + * parameter `backfill_id`). * 3. [Close](close-backfill) the backfill, propagating the update in past usage throughout Orb. * * Changes from a backfill are not reflected until the backfill is closed, so you won’t need to @@ -79,8 +85,7 @@ interface BackfillService { * * The list of backfills is ordered starting from the most recently created backfill. The * response also includes [`pagination_metadata`](/api-reference/pagination), which lets the - * caller retrieve the next page of results if they exist. More information about pagination can - * be found in the [Pagination-metadata schema](pagination). + * caller retrieve the next page of results if they exist. */ fun list(): EventBackfillListPage = list(EventBackfillListParams.none()) 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 4e5f90e1b..8f64789ea 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 @@ -30,6 +30,11 @@ import com.withorb.api.models.EventBackfillRevertResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class BackfillServiceImpl internal constructor(private val clientOptions: ClientOptions) : BackfillService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt index 357dfcaf5..2cdd25092 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeService.kt @@ -10,6 +10,11 @@ import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ interface VolumeService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt index 5f8b4f8f5..0e1688540 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/VolumeServiceImpl.kt @@ -18,6 +18,11 @@ import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes import java.util.function.Consumer +/** + * The [Event](/core-concepts#event) resource represents a usage event that has been created for a + * customer. Events are the core of Orb's usage-based billing model, and are used to calculate the + * usage charges for a given billing period. + */ class VolumeServiceImpl internal constructor(private val clientOptions: ClientOptions) : VolumeService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt new file mode 100644 index 000000000..1356c2da5 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseService.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse +import java.util.function.Consumer + +interface ExternalLicenseService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ExternalLicenseService + + /** + * Returns usage and remaining credits for a license identified by its external license ID. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + ): LicenseExternalLicenseGetUsageResponse = + getUsage(externalLicenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseExternalLicenseGetUsageResponse = + getUsage(params.toBuilder().externalLicenseId(externalLicenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams + ): LicenseExternalLicenseGetUsageResponse = getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseExternalLicenseGetUsageResponse + + /** + * A view of [ExternalLicenseService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ExternalLicenseService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /licenses/external_licenses/{external_license_id}/usage`, but is otherwise the same as + * [ExternalLicenseService.getUsage]. + */ + @MustBeClosed + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + ): HttpResponseFor = + getUsage(externalLicenseId, params, RequestOptions.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + externalLicenseId: String, + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getUsage( + params.toBuilder().externalLicenseId(externalLicenseId).build(), + requestOptions, + ) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseExternalLicenseGetUsageParams + ): HttpResponseFor = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt new file mode 100644 index 000000000..58963b23c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import com.withorb.api.models.LicenseExternalLicenseGetUsageResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ExternalLicenseServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalLicenseService { + + private val withRawResponse: ExternalLicenseService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ExternalLicenseService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ExternalLicenseService = + ExternalLicenseServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): LicenseExternalLicenseGetUsageResponse = + // get /licenses/external_licenses/{external_license_id}/usage + withRawResponse().getUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalLicenseService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ExternalLicenseService.WithRawResponse = + ExternalLicenseServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseExternalLicenseGetUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalLicenseId", params.externalLicenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "external_licenses", params._pathParam(0), "usage") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt new file mode 100644 index 000000000..2a3f5ea9e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageService.kt @@ -0,0 +1,152 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.google.errorprone.annotations.MustBeClosed +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse +import java.util.function.Consumer + +interface UsageService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UsageService + + /** + * Returns usage and remaining credits for all licenses of a given type on a subscription. + * + * Date range defaults to the current billing period if not specified. + */ + fun getAllUsage(params: LicenseUsageGetAllUsageParams): LicenseUsageGetAllUsageResponse = + getAllUsage(params, RequestOptions.none()) + + /** @see getAllUsage */ + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetAllUsageResponse + + /** + * Returns usage and remaining credits for a specific license over a date range. + * + * Date range defaults to the current billing period if not specified. + */ + fun getUsage(licenseId: String): LicenseUsageGetUsageResponse = + getUsage(licenseId, LicenseUsageGetUsageParams.none()) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetUsageResponse = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + ): LicenseUsageGetUsageResponse = getUsage(licenseId, params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): LicenseUsageGetUsageResponse + + /** @see getUsage */ + fun getUsage(params: LicenseUsageGetUsageParams): LicenseUsageGetUsageResponse = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage(licenseId: String, requestOptions: RequestOptions): LicenseUsageGetUsageResponse = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + + /** A view of [UsageService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UsageService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /licenses/usage`, but is otherwise the same as + * [UsageService.getAllUsage]. + */ + @MustBeClosed + fun getAllUsage( + params: LicenseUsageGetAllUsageParams + ): HttpResponseFor = + getAllUsage(params, RequestOptions.none()) + + /** @see getAllUsage */ + @MustBeClosed + fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /licenses/{license_id}/usage`, but is otherwise the + * same as [UsageService.getUsage]. + */ + @MustBeClosed + fun getUsage(licenseId: String): HttpResponseFor = + getUsage(licenseId, LicenseUsageGetUsageParams.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getUsage(params.toBuilder().licenseId(licenseId).build(), requestOptions) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + licenseId: String, + params: LicenseUsageGetUsageParams = LicenseUsageGetUsageParams.none(), + ): HttpResponseFor = + getUsage(licenseId, params, RequestOptions.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: LicenseUsageGetUsageParams + ): HttpResponseFor = getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + licenseId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + getUsage(licenseId, LicenseUsageGetUsageParams.none(), requestOptions) + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt new file mode 100644 index 000000000..fac19c82b --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceImpl.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.core.ClientOptions +import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired +import com.withorb.api.core.handlers.errorBodyHandler +import com.withorb.api.core.handlers.errorHandler +import com.withorb.api.core.handlers.jsonHandler +import com.withorb.api.core.http.HttpMethod +import com.withorb.api.core.http.HttpRequest +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponse.Handler +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.core.http.parseable +import com.withorb.api.core.prepare +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetAllUsageResponse +import com.withorb.api.models.LicenseUsageGetUsageParams +import com.withorb.api.models.LicenseUsageGetUsageResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class UsageServiceImpl internal constructor(private val clientOptions: ClientOptions) : + UsageService { + + private val withRawResponse: UsageService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UsageService = + UsageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): LicenseUsageGetAllUsageResponse = + // get /licenses/usage + withRawResponse().getAllUsage(params, requestOptions).parse() + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): LicenseUsageGetUsageResponse = + // get /licenses/{license_id}/usage + withRawResponse().getUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UsageService.WithRawResponse = + UsageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getAllUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getAllUsage( + params: LicenseUsageGetAllUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", "usage") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getAllUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: LicenseUsageGetUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("licenseId", params.licenseId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("licenses", params._pathParam(0), "usage") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} 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 0770d8637..884dd8074 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 @@ -11,6 +11,11 @@ import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface ExternalPlanIdService { /** @@ -26,8 +31,8 @@ interface ExternalPlanIdService { fun withOptions(modifier: Consumer): ExternalPlanIdService /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing - * plan. + * This endpoint can be used to update the `external_plan_id`, `description`, and `metadata` of + * an existing plan. * * Other fields on a plan are currently immutable. */ 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 632faabfd..504d8dab2 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 @@ -22,6 +22,11 @@ import com.withorb.api.models.PlanExternalPlanIdUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdService { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt index 19dc5cbd5..d2c1e4a61 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationService.kt @@ -14,6 +14,11 @@ import com.withorb.api.models.PlanMigrationRetrieveParams import com.withorb.api.models.PlanMigrationRetrieveResponse import java.util.function.Consumer +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ interface MigrationService { /** diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt index 1dd143277..83d679507 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/MigrationServiceImpl.kt @@ -26,6 +26,11 @@ import com.withorb.api.models.PlanMigrationRetrieveResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by + * a customer. Plans define the billing behavior of the subscription. You can see more about how to + * configure prices in the [Price resource](/reference/price). + */ class MigrationServiceImpl internal constructor(private val clientOptions: ClientOptions) : MigrationService { 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 6b6feccb9..e7731b31a 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 @@ -11,6 +11,18 @@ import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams import java.util.function.Consumer +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ interface ExternalPriceIdService { /** 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 af5d6859f..bd02969d1 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 @@ -22,6 +22,18 @@ import com.withorb.api.models.PriceExternalPriceIdUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull +/** + * The Price resource represents a price that can be billed on a subscription, resulting in a charge + * on an invoice in the form of an invoice line item. Prices take a quantity and determine an amount + * to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given Price object. The model_type field determines the key for the + * configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ class ExternalPriceIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdService { diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt b/orb-java-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt index 4dd94b267..97c34c8f5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/TestServerExtension.kt @@ -15,25 +15,12 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { } catch (e: Exception) { throw RuntimeException( """ - The test suite will not run without a mock Prism server running against your OpenAPI spec. + The test suite will not run without a mock server running against your OpenAPI spec. You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests that require the mock server. - To fix: - - 1. Install Prism (requires Node 16+): - - With npm: - $ npm install -g @stoplight/prism-cli - - With yarn: - $ yarn global add @stoplight/prism-cli - - 2. Run the mock server - - To run the server, pass in the path of your OpenAPI spec to the prism command: - $ prism mock path/to/your.openapi.yml + To fix run `./scripts/mock` in a separate terminal. """ .trimIndent(), e, diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/ClientOptionsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/ClientOptionsTest.kt index 24e6362fd..1a788d837 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/ClientOptionsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/ClientOptionsTest.kt @@ -16,6 +16,29 @@ internal class ClientOptionsTest { private val httpClient = mock() + @Test + fun putHeader_canOverwriteDefaultHeader() { + val clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .putHeader("User-Agent", "My User Agent") + .apiKey("My API Key") + .build() + + assertThat(clientOptions.headers.values("User-Agent")).containsExactly("My User Agent") + } + + @Test + fun toBuilder_apiKeyAuthCanBeUpdated() { + var clientOptions = + ClientOptions.builder().httpClient(httpClient).apiKey("My API Key").build() + + clientOptions = clientOptions.toBuilder().apiKey("another My API Key").build() + + assertThat(clientOptions.headers.values("Authorization")) + .containsExactly("Bearer another My API Key") + } + @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { var clientOptions = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt index a8bc18d22..0538190b8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/ObjectMappersTest.kt @@ -3,12 +3,14 @@ package com.withorb.api.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDate +import java.time.LocalTime import java.time.OffsetDateTime +import java.time.ZoneOffset import kotlin.reflect.KClass import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource import org.junitpioneer.jupiter.cartesian.CartesianTest @@ -72,11 +74,34 @@ internal class ObjectMappersTest { } } - enum class LenientOffsetDateTimeTestCase(val string: String) { - DATE("1998-04-21"), - DATE_TIME("1998-04-21T04:00:00"), - ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), - ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + enum class LenientOffsetDateTimeTestCase( + val string: String, + val expectedOffsetDateTime: OffsetDateTime, + ) { + DATE( + "1998-04-21", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(0, 0), ZoneOffset.UTC), + ), + DATE_TIME( + "1998-04-21T04:00:00", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(4, 0), ZoneOffset.UTC), + ), + ZONED_DATE_TIME_1( + "1998-04-21T04:00:00+03:00", + expectedOffsetDateTime = + OffsetDateTime.of( + LocalDate.of(1998, 4, 21), + LocalTime.of(4, 0), + ZoneOffset.ofHours(3), + ), + ), + ZONED_DATE_TIME_2( + "1998-04-21T04:00:00Z", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(4, 0), ZoneOffset.UTC), + ), } @ParameterizedTest @@ -85,6 +110,8 @@ internal class ObjectMappersTest { val jsonMapper = jsonMapper() val json = jsonMapper.writeValueAsString(testCase.string) - assertDoesNotThrow { jsonMapper().readValue(json) } + val offsetDateTime = jsonMapper().readValue(json) + + assertThat(offsetDateTime).isEqualTo(testCase.expectedOffsetDateTime) } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt new file mode 100644 index 000000000..b7a705e1d --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HttpRequestBodiesTest.kt @@ -0,0 +1,739 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core.http + +import com.withorb.api.core.MultipartField +import com.withorb.api.core.jsonMapper +import java.io.ByteArrayOutputStream +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HttpRequestBodiesTest { + + @Test + fun multipartFormData_serializesFieldWithFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "file" to + MultipartField.builder() + .value("hello") + .filename("hello.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = body.contentType()!!.substringAfter("multipart/form-data; boundary=") + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="file"; filename="hello.txt" + |Content-Type: text/plain + | + |hello + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesFieldWithoutFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("value") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStream() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "stream content".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |stream content + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesByteArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "binary" to + MultipartField.builder() + .value("abc".toByteArray()) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="binary" + |Content-Type: application/octet-stream + | + |abc + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesBooleanValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "flag" to + MultipartField.builder() + .value(true) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="flag" + |Content-Type: text/plain + | + |true + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNumberValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "count" to + MultipartField.builder().value(42).contentType("text/plain").build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="count" + |Content-Type: text/plain + | + |42 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNullValueAsNoParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "present" to + MultipartField.builder() + .value("yes") + .contentType("text/plain") + .build(), + "absent" to + MultipartField.builder() + .value(null as String?) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="present" + |Content-Type: text/plain + | + |yes + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "items" to + MultipartField.builder>() + .value(listOf("alpha", "beta", "gamma")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="items[]" + |Content-Type: text/plain + | + |alpha + |--$boundary + |Content-Disposition: form-data; name="items[]" + |Content-Type: text/plain + | + |beta + |--$boundary + |Content-Disposition: form-data; name="items[]" + |Content-Type: text/plain + | + |gamma + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesObjectAsNestedParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "meta" to + MultipartField.builder>() + .value(mapOf("key1" to "val1", "key2" to "val2")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="meta[key1]" + |Content-Type: text/plain + | + |val1 + |--$boundary + |Content-Disposition: form-data; name="meta[key2]" + |Content-Type: text/plain + | + |val2 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesMultipleFields() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "name" to + MultipartField.builder() + .value("Alice") + .contentType("text/plain") + .build(), + "age" to + MultipartField.builder().value(30).contentType("text/plain").build(), + "file" to + MultipartField.builder() + .value("file contents") + .filename("doc.txt") + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="name" + |Content-Type: text/plain + | + |Alice + |--$boundary + |Content-Disposition: form-data; name="age" + |Content-Type: text/plain + | + |30 + |--$boundary + |Content-Disposition: form-data; name="file"; filename="doc.txt" + |Content-Type: text/plain + | + |file contents + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_quotesSpecialCharactersInNameAndFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field\nname" to + MultipartField.builder() + .value("value") + .filename("file\r\"name.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field%0Aname"; filename="file%0D%22name.txt" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_writeIsRepeatable() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("repeatable") + .contentType("text/plain") + .build() + ), + ) + + val output1 = ByteArrayOutputStream() + body.writeTo(output1) + val output2 = ByteArrayOutputStream() + body.writeTo(output2) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output1.size().toLong()) + val boundary = boundary(body) + val expected = + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |repeatable + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + assertThat(output1.toString("UTF-8")).isEqualTo(expected) + assertThat(output2.toString("UTF-8")).isEqualTo(expected) + } + + @Test + fun multipartFormData_serializesByteArrayInputStream() { + // ByteArrayInputStream is specifically handled as repeatable with known content length. + val inputStream = "byte array stream".byteInputStream() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |byte array stream + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStreamWithFilename() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "file data".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "upload" to + MultipartField.builder() + .value(inputStream) + .filename("upload.bin") + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="upload"; filename="upload.bin" + |Content-Type: application/octet-stream + | + |file data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNestedArrayInObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder>>() + .value(mapOf("tags" to listOf("a", "b"))) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data[tags][]" + |Content-Type: text/plain + | + |a + |--$boundary + |Content-Disposition: form-data; name="data[tags][]" + |Content-Type: text/plain + | + |b + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_contentLengthIsUnknownWhenInputStreamPresent() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "text" to + MultipartField.builder() + .value("hello") + .contentType("text/plain") + .build(), + "stream" to + MultipartField.builder() + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the + // non-repeatable code path. + .value("data".byteInputStream().buffered()) + .contentType("application/octet-stream") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="text" + |Content-Type: text/plain + | + |hello + |--$boundary + |Content-Disposition: form-data; name="stream" + |Content-Type: application/octet-stream + | + |data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "items" to + MultipartField.builder>() + .value(emptyList()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "meta" to + MultipartField.builder>() + .value(emptyMap()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + private fun boundary(body: HttpRequestBody): String = + body.contentType()!!.substringAfter("multipart/form-data; boundary=") +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/LoggingHttpClientTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/LoggingHttpClientTest.kt new file mode 100644 index 000000000..d92e5b464 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/LoggingHttpClientTest.kt @@ -0,0 +1,1000 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core.http + +import com.withorb.api.core.LogLevel +import com.withorb.api.core.RequestOptions +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import java.io.IOException +import java.io.InputStream +import java.io.OutputStream +import java.io.PrintStream +import java.nio.charset.StandardCharsets +import java.time.Clock +import java.time.Instant +import java.time.ZoneOffset +import java.util.concurrent.CompletableFuture +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource + +@ResourceLock("stderr") +internal class LoggingHttpClientTest { + + private lateinit var originalErr: PrintStream + private lateinit var errContent: ByteArrayOutputStream + + @BeforeEach + fun beforeEach() { + originalErr = System.err + errContent = ByteArrayOutputStream() + System.setErr(PrintStream(errContent)) + } + + @AfterEach + fun afterEach() { + System.setErr(originalErr) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun offLevel_noOutput(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.OFF) + + val response = client.execute(simpleGetRequest(), async).apply { body().readBytes() } + + assertThat(response.statusCode()).isEqualTo(200) + assertThat(stderrOutput()).isEmpty() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsGetRequest(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.INFO) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 200 (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsPostRequestWithBodySize(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.INFO) + + client.execute(postRequestWithBody("""{"key":"value"}"""), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> POST https://api.example.com/v1/resources (15-byte body) + |<-- 200 (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsRequestWithUnknownLengthBody(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.INFO) + + client + .execute(postRequestWithBody("""{"key":"value"}""", contentLength = -1L), async) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> POST https://api.example.com/v1/resources (unknown-length body) + |<-- 200 (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsResponseStatusAndDuration(async: Boolean) { + val clock = + clockFrom( + Instant.parse("1998-04-21T00:00:00Z"), + Instant.parse("1998-04-21T00:00:01.234Z"), + ) + val client = loggingClient(fakeHttpClient(statusCode = 201), LogLevel.INFO, clock) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 201 (1s 234ms) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_logsResponseContentLength(async: Boolean) { + val headers = + Headers.builder().put("Content-Length", "42").put("Content-Type", "text/plain").build() + val client = loggingClient(fakeHttpClient(responseHeaders = headers), LogLevel.INFO) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 200 (0s, 42-byte body) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_doesNotLogHeaders(async: Boolean) { + val headers = Headers.builder().put("X-Custom", "visible").build() + val client = loggingClient(fakeHttpClient(responseHeaders = headers), LogLevel.INFO) + + client + .execute( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("v1") + .putHeader("X-Request-Custom", "req-value") + .build(), + async, + ) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1 + |<-- 200 (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsGetWithEndMarker(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.DEBUG) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsRequestAndResponseHeaders(async: Boolean) { + val responseHeaders = + Headers.builder() + .put("X-Response-Id", "abc-123") + .put("Content-Type", "text/plain") + .build() + val client = + loggingClient(fakeHttpClient(responseHeaders = responseHeaders), LogLevel.DEBUG) + + client + .execute( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("test") + .putHeader("X-Custom", "my-value") + .build(), + async, + ) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/test + |X-Custom: my-value + |--> END GET + | + |<-- 200 (0s) + |Content-Type: text/plain + |X-Response-Id: abc-123 + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_redactsSensitiveHeaders(async: Boolean) { + val client = + loggingClient( + fakeHttpClient(), + LogLevel.DEBUG, + redactedHeaders = setOf("Authorization", "X-Secret"), + ) + + client + .execute( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("test") + .putHeader("Authorization", "Bearer token-123") + .putHeader("X-Secret", "secret-value") + .putHeader("X-Public", "public-value") + .build(), + async, + ) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/test + |Authorization: ██ + |X-Public: public-value + |X-Secret: ██ + |--> END GET + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_redactsHeadersCaseInsensitively(async: Boolean) { + val client = + loggingClient( + fakeHttpClient(), + LogLevel.DEBUG, + redactedHeaders = setOf("Authorization"), + ) + + client + .execute( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("test") + .putHeader("authorization", "Bearer secret") + .build(), + async, + ) + .body() + .readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/test + |authorization: ██ + |--> END GET + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsRequestBody(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.DEBUG) + val body = """{"name":"test","value":42}""" + + client.execute(postRequestWithBody(body), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> POST https://api.example.com/v1/resources (26-byte body) + | + |{"name":"test","value":42} + |--> END POST (26-byte body) + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsResponseBody(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + val response = client.execute(simpleGetRequest(), async) + val body = response.body().readBytes().toString(StandardCharsets.UTF_8) + + assertThat(body).isEqualTo(responseBody) + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + | + |{"id":1,"status":"ok"} + |<-- END HTTP (22-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsBinaryResponseBodyAsOmitted(async: Boolean) { + val binaryBody = ByteArray(256) { it.toByte() } + val client = loggingClient(fakeHttpClient(responseBody = binaryBody), LogLevel.DEBUG) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + | + |(binary body omitted) + |<-- END HTTP (256-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsMultilineResponseBody(async: Boolean) { + val multilineBody = "line1\nline2\nline3" + val headers = Headers.builder().put("Content-Type", "text/plain; charset=utf-8").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = multilineBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: text/plain; charset=utf-8 + | + |line1 + |line2 + |line3 + |<-- END HTTP (17-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsResponseBodyWithExplicitCharset(async: Boolean) { + val responseBody = "héllo wörld" + val headers = Headers.builder().put("Content-Type", "text/plain; charset=utf-8").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: text/plain; charset=utf-8 + | + |héllo wörld + |<-- END HTTP (13-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsResponseBodyWithNoContentType(async: Boolean) { + val responseBody = "plain text body" + val client = + loggingClient( + fakeHttpClient(responseBody = responseBody.toByteArray(StandardCharsets.UTF_8)), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + | + |plain text body + |<-- END HTTP (15-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsEmptyResponseBody(async: Boolean) { + val client = loggingClient(fakeHttpClient(), LogLevel.DEBUG) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |<-- END HTTP (0-byte body) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsEndHttpMarkerOnEarlyClose(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + val body = client.execute(simpleGetRequest(), async).body() + body.read(ByteArray(5)) + body.close() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + | + |{"id" + |<-- END HTTP (5-byte body, closed early) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsEndHttpMarkerOnCloseWithoutReading(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).body().close() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + |<-- END HTTP (0-byte body, closed early) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsEndHttpMarkerWhenResponseClosedAfterPartialRead(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + val response = client.execute(simpleGetRequest(), async) + response.body().read(ByteArray(5)) + response.close() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + | + |{"id" + |<-- END HTTP (5-byte body, closed early) + | + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_doesNotLogEndHttpMarkerWhenResponseClosedWithoutBodyAccess(async: Boolean) { + val responseBody = """{"id":1,"status":"ok"}""" + val headers = Headers.builder().put("Content-Type", "application/json").build() + val client = + loggingClient( + fakeHttpClient( + responseHeaders = headers, + responseBody = responseBody.toByteArray(StandardCharsets.UTF_8), + ), + LogLevel.DEBUG, + ) + + client.execute(simpleGetRequest(), async).close() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- 200 (0s) + |Content-Type: application/json + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun errorLevel_logsRequestFailure(async: Boolean) { + val clock = + clockFrom( + Instant.parse("1998-04-21T00:00:00Z"), + Instant.parse("1998-04-21T00:00:01.234Z"), + ) + val client = + loggingClient( + failingHttpClient(IOException("Connection refused")), + LogLevel.ERROR, + clock, + ) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- !! IOException: Connection refused (1s 234ms) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun infoLevel_doesNotLogRequestFailure(async: Boolean) { + val client = + loggingClient(failingHttpClient(IOException("Connection refused")), LogLevel.INFO) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun debugLevel_logsRequestFailureAfterHeaders(async: Boolean) { + val client = + loggingClient(failingHttpClient(IOException("Connection refused")), LogLevel.DEBUG) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |--> END GET + | + |<-- !! IOException: Connection refused (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun errorLevel_logsRequestFailureWithoutMessage(async: Boolean) { + val client = loggingClient(failingHttpClient(IOException()), LogLevel.ERROR) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- !! IOException (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun offLevel_doesNotLogRequestFailure(async: Boolean) { + val client = + loggingClient(failingHttpClient(IOException("Connection refused")), LogLevel.OFF) + + assertThatThrownBy { client.execute(simpleGetRequest(), async) } + + assertThat(stderrOutput()).isEmpty() + } + + @Test + fun errorLevel_logsExecuteAsyncSynchronousThrow() { + val error = IOException("Connection refused") + val client = + loggingClient( + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse = throw UnsupportedOperationException() + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = throw error + + override fun close() {} + }, + LogLevel.ERROR, + ) + + assertThatThrownBy { client.execute(simpleGetRequest(), async = true) }.isSameAs(error) + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- !! IOException: Connection refused (0s) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun durationFormat_seconds(async: Boolean) { + val clock = + clockFrom( + Instant.parse("1998-04-21T00:00:00Z"), + Instant.parse("1998-04-21T00:00:02.500Z"), + ) + val client = loggingClient(fakeHttpClient(), LogLevel.INFO, clock) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 200 (2s 500ms) + |""" + .trimMargin() + ) + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun durationFormat_minutesAndSeconds(async: Boolean) { + val clock = + clockFrom( + Instant.parse("1998-04-21T00:00:00Z"), + Instant.parse("1998-04-21T00:01:40.467Z"), + ) + val client = loggingClient(fakeHttpClient(), LogLevel.INFO, clock) + + client.execute(simpleGetRequest(), async).body().readBytes() + + assertThat(stderrOutput()) + .isEqualTo( + """ + |--> GET https://api.example.com/v1/resources + |<-- 200 (1m 40s 467ms) + |""" + .trimMargin() + ) + } + + @Test + fun builder_toBuilder_roundtrips() { + val delegate = fakeHttpClient() + val clock = Clock.fixed(Instant.parse("1998-04-21T00:00:00Z"), ZoneOffset.UTC) + val client = + LoggingHttpClient.builder() + .httpClient(delegate) + .level(LogLevel.DEBUG) + .redactedHeaders(setOf("X-Secret")) + .clock(clock) + .build() + + val rebuilt = client.toBuilder().build() + + assertThat(rebuilt.httpClient).isSameAs(delegate) + assertThat(rebuilt.level).isEqualTo(LogLevel.DEBUG) + assertThat(rebuilt.redactedHeaders).containsExactly("X-Secret") + assertThat(rebuilt.clock).isEqualTo(clock) + } + + @Test + fun close_delegatesToUnderlyingClient() { + var closed = false + val delegate = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse = throw UnsupportedOperationException() + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = throw UnsupportedOperationException() + + override fun close() { + closed = true + } + } + val client = loggingClient(delegate, LogLevel.OFF) + + client.close() + + assertThat(closed).isTrue() + } + + private fun stderrOutput(): String = errContent.toString("UTF-8") + + private fun loggingClient( + httpClient: HttpClient, + level: LogLevel, + clock: Clock = clockFrom(Instant.parse("1998-04-21T00:00:00Z")), + redactedHeaders: Set = + setOf("authorization", "api-key", "x-api-key", "cookie", "set-cookie"), + ): LoggingHttpClient = + LoggingHttpClient.builder() + .httpClient(httpClient) + .level(level) + .clock(clock) + .redactedHeaders(redactedHeaders) + .build() + + private fun simpleGetRequest(): HttpRequest = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("v1") + .addPathSegment("resources") + .build() + + private fun postRequestWithBody( + body: String, + contentType: String = "application/json", + contentLength: Long? = null, + ): HttpRequest = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl("https://api.example.com") + .addPathSegment("v1") + .addPathSegment("resources") + .body( + object : HttpRequestBody { + private val bytes = body.toByteArray(StandardCharsets.UTF_8) + + override fun writeTo(outputStream: OutputStream) { + outputStream.write(bytes) + } + + override fun contentType(): String = contentType + + override fun contentLength(): Long = contentLength ?: bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + ) + .build() + + private fun fakeHttpClient( + statusCode: Int = 200, + responseHeaders: Headers = Headers.builder().build(), + responseBody: ByteArray = ByteArray(0), + ): HttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + // Consume the request body if present to trigger logging. + request.body?.let { + val out = ByteArrayOutputStream() + it.writeTo(out) + } + return fakeResponse(statusCode, responseHeaders, responseBody) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = + CompletableFuture.completedFuture(execute(request, requestOptions)) + + override fun close() {} + } + + private fun failingHttpClient(error: Throwable): HttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + request.body?.let { + val out = ByteArrayOutputStream() + it.writeTo(out) + } + throw error + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val future = CompletableFuture() + future.completeExceptionally(error) + return future + } + + override fun close() {} + } + + private fun fakeResponse(statusCode: Int, headers: Headers, body: ByteArray): HttpResponse = + object : HttpResponse { + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): InputStream = ByteArrayInputStream(body) + + override fun close() {} + } + + private fun clockFrom(vararg instants: Instant): Clock = + object : Clock() { + private var index = 0 + + override fun getZone() = ZoneOffset.UTC + + override fun withZone(zone: java.time.ZoneId?) = this + + override fun instant(): Instant { + val instant = instants[index % instants.size] + index++ + return instant + } + } + + 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/core/http/RetryingHttpClientTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/RetryingHttpClientTest.kt index 4170f41f5..6412e46d2 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 @@ -1,6 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + package com.withorb.api.core.http -import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.matching +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.resetAllScenarios +import com.github.tomakehurst.wiremock.client.WireMock.serviceUnavailable +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario @@ -9,7 +20,11 @@ import com.withorb.api.core.RequestOptions import com.withorb.api.core.Sleeper import com.withorb.api.errors.OrbRetryableException import java.io.InputStream +import java.time.Clock import java.time.Duration +import java.time.OffsetDateTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach @@ -25,6 +40,21 @@ internal class RetryingHttpClientTest { private lateinit var baseUrl: String private lateinit var httpClient: HttpClient + private class RecordingSleeper : Sleeper { + val durations = mutableListOf() + + override fun sleep(duration: Duration) { + durations.add(duration) + } + + override fun sleepAsync(duration: Duration): CompletableFuture { + durations.add(duration) + return CompletableFuture.completedFuture(null) + } + + override fun close() {} + } + @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { baseUrl = wmRuntimeInfo.httpBaseUrl @@ -75,7 +105,8 @@ internal class RetryingHttpClientTest { @ValueSource(booleans = [false, true]) fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = retryingHttpClientBuilder().build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).build() val response = retryingClient.execute( @@ -89,6 +120,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @@ -100,8 +132,12 @@ internal class RetryingHttpClientTest { .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) .willReturn(ok()) ) + val sleeper = RecordingSleeper() val retryingClient = - retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + retryingHttpClientBuilder(sleeper) + .maxRetries(2) + .idempotencyHeader("X-Some-Header") + .build() val response = retryingClient.execute( @@ -115,20 +151,20 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withRetryAfterHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) // First we fail with a retry after header given as a date .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -147,7 +183,13 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + // Fix the clock to 5 seconds before the Retry-After date so the date-based backoff is + // deterministic. + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -175,19 +217,20 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("2")), ) + assertThat(sleeper.durations) + .containsExactly(Duration.ofSeconds(5), Duration.ofMillis(1234)) assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -197,7 +240,11 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -216,6 +263,7 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("42")), ) + assertThat(sleeper.durations).containsExactly(Duration.ofSeconds(5)) assertNoResponseLeaks() } @@ -236,7 +284,8 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() val response = retryingClient.execute( @@ -250,6 +299,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(10)) assertNoResponseLeaks() } @@ -290,21 +340,12 @@ internal class RetryingHttpClientTest { override fun close() = httpClient.close() } + val sleeper = RecordingSleeper() val retryingClient = RetryingHttpClient.builder() .httpClient(failingHttpClient) .maxRetries(2) - .sleeper( - object : Sleeper { - - override fun sleep(duration: Duration) {} - - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) - - override fun close() {} - } - ) + .sleeper(sleeper) .build() val response = @@ -328,25 +369,153 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("0")), ) + // Exponential backoff with jitter: 0.5s * jitter where jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoff(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(3).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + // All retries exhausted; the last 503 response is returned. + assertThat(response.statusCode()).isEqualTo(503) + verify(4, postRequestedFor(urlPathEqualTo("/something"))) + // Exponential backoff with jitter: backoff = min(0.5 * 2^(retries-1), 8) * jitter where + // jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(3) + // retries=1: 0.5s * [0.75, 1.0] + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + // retries=2: 1s * [0.75, 1.0] + assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) + // retries=3: 2s * [0.75, 1.0] + assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) assertNoResponseLeaks() } - private fun retryingHttpClientBuilder() = - RetryingHttpClient.builder() - .httpClient(httpClient) - // Use a no-op `Sleeper` to make the test fast. - .sleeper( - object : Sleeper { + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoffCap(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(6).build() - override fun sleep(duration: Duration) {} + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) + assertThat(response.statusCode()).isEqualTo(503) + verify(7, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).hasSize(6) + // retries=5: backoff hits the 8s cap * [0.75, 1.0] + assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + // retries=6: still capped at 8s * [0.75, 1.0] + assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + assertNoResponseLeaks() + } - override fun close() {} - } + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsPriorityOverRetryAfter(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable() + .withHeader("Retry-After-Ms", "50") + .withHeader("Retry-After", "2") + ) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Retry-After-Ms (50ms) takes priority over Retry-After (2s). + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(50)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterUnparseable(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After", "not-a-date-or-number")) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, ) + assertThat(response.statusCode()).isEqualTo(200) + // Unparseable Retry-After falls through to exponential backoff. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder( + sleeper: RecordingSleeper, + clock: Clock = Clock.systemUTC(), + ) = RetryingHttpClient.builder().httpClient(httpClient).sleeper(sleeper).clock(clock) + 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/AccountingProviderConfigTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AccountingProviderConfigTest.kt index f4ba287e5..551c0b8cf 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AccountingProviderConfigTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AccountingProviderConfigTest.kt @@ -14,11 +14,12 @@ internal class AccountingProviderConfigTest { val accountingProviderConfig = AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() assertThat(accountingProviderConfig.externalProviderId()).isEqualTo("external_provider_id") - assertThat(accountingProviderConfig.providerType()).isEqualTo("provider_type") + assertThat(accountingProviderConfig.providerType()) + .isEqualTo(AccountingProviderConfig.ProviderType.QUICKBOOKS) } @Test @@ -27,7 +28,7 @@ internal class AccountingProviderConfigTest { val accountingProviderConfig = AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() val roundtrippedAccountingProviderConfig = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt index 49e22110c..a3dec90ea 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostTest.kt @@ -62,6 +62,7 @@ internal class AggregatedCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -85,6 +86,7 @@ internal class AggregatedCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -141,6 +143,13 @@ internal class AggregatedCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -201,6 +210,7 @@ internal class AggregatedCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -222,6 +232,7 @@ internal class AggregatedCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -278,6 +289,13 @@ internal class AggregatedCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -346,6 +364,7 @@ internal class AggregatedCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -369,6 +388,7 @@ internal class AggregatedCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -425,6 +445,13 @@ internal class AggregatedCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt index f53447480..54368bc48 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParamsTest.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,7 +14,22 @@ internal class AlertCreateForSubscriptionParamsTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .addPriceFilter( + AlertCreateForSubscriptionParams.PriceFilter.builder() + .field(AlertCreateForSubscriptionParams.PriceFilter.Field.PRICE_ID) + .operator(AlertCreateForSubscriptionParams.PriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .pricingUnitId("pricing_unit_id") + .addThresholdOverride( + AlertCreateForSubscriptionParams.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) .build() } @@ -38,14 +54,46 @@ internal class AlertCreateForSubscriptionParamsTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .addPriceFilter( + AlertCreateForSubscriptionParams.PriceFilter.builder() + .field(AlertCreateForSubscriptionParams.PriceFilter.Field.PRICE_ID) + .operator(AlertCreateForSubscriptionParams.PriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .pricingUnitId("pricing_unit_id") + .addThresholdOverride( + AlertCreateForSubscriptionParams.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) .build() val body = params._body() assertThat(body.thresholds()).containsExactly(Threshold.builder().value(0.0).build()) assertThat(body.type()).isEqualTo(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + assertThat(body.groupingKeys().getOrNull()).containsExactly("string") assertThat(body.metricId()).contains("metric_id") + assertThat(body.priceFilters().getOrNull()) + .containsExactly( + AlertCreateForSubscriptionParams.PriceFilter.builder() + .field(AlertCreateForSubscriptionParams.PriceFilter.Field.PRICE_ID) + .operator(AlertCreateForSubscriptionParams.PriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + assertThat(body.pricingUnitId()).contains("pricing_unit_id") + assertThat(body.thresholdOverrides().getOrNull()) + .containsExactly( + AlertCreateForSubscriptionParams.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt index 8221015e9..c7c725dd8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertListPageResponseTest.kt @@ -44,6 +44,21 @@ internal class AlertListPageResponseTest { .thresholdValue(0.0) .build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) + .addPriceFilter( + Alert.PriceFilter.builder() + .field(Alert.PriceFilter.Field.PRICE_ID) + .operator(Alert.PriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .addThresholdOverride( + Alert.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) .build() ) .paginationMetadata( @@ -79,6 +94,21 @@ internal class AlertListPageResponseTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) + .addPriceFilter( + Alert.PriceFilter.builder() + .field(Alert.PriceFilter.Field.PRICE_ID) + .operator(Alert.PriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .addThresholdOverride( + Alert.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) .build() ) assertThat(alertListPageResponse.paginationMetadata()) @@ -120,6 +150,21 @@ internal class AlertListPageResponseTest { .thresholdValue(0.0) .build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) + .addPriceFilter( + Alert.PriceFilter.builder() + .field(Alert.PriceFilter.Field.PRICE_ID) + .operator(Alert.PriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .addThresholdOverride( + Alert.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) .build() ) .paginationMetadata( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt index 8a8fc960b..6b60ed782 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertTest.kt @@ -40,6 +40,21 @@ internal class AlertTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) + .addPriceFilter( + Alert.PriceFilter.builder() + .field(Alert.PriceFilter.Field.PRICE_ID) + .operator(Alert.PriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .addThresholdOverride( + Alert.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) .build() assertThat(alert.id()).isEqualTo("XuxCbt7x9L82yyeF") @@ -72,6 +87,23 @@ internal class AlertTest { .containsExactly( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + assertThat(alert.groupingKeys().getOrNull()).containsExactly("string") + assertThat(alert.licenseType()).contains(Alert.LicenseType.builder().id("id").build()) + assertThat(alert.priceFilters().getOrNull()) + .containsExactly( + Alert.PriceFilter.builder() + .field(Alert.PriceFilter.Field.PRICE_ID) + .operator(Alert.PriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + assertThat(alert.thresholdOverrides().getOrNull()) + .containsExactly( + Alert.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) } @Test @@ -104,6 +136,21 @@ internal class AlertTest { .addBalanceAlertStatus( Alert.BalanceAlertStatus.builder().inAlert(true).thresholdValue(0.0).build() ) + .addGroupingKey("string") + .licenseType(Alert.LicenseType.builder().id("id").build()) + .addPriceFilter( + Alert.PriceFilter.builder() + .field(Alert.PriceFilter.Field.PRICE_ID) + .operator(Alert.PriceFilter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .addThresholdOverride( + Alert.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) .build() val roundtrippedAlert = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt index 5f9611a71..d66705ae7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationTest.kt @@ -29,6 +29,7 @@ internal class AllocationTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() assertThat(allocation.allowsRollover()).isEqualTo(true) @@ -48,6 +49,7 @@ internal class AllocationTest { .addValue("string") .build() ) + assertThat(allocation.licenseTypeId()).contains("license_type_id") } @Test @@ -70,6 +72,7 @@ internal class AllocationTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() val roundtrippedAllocation = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt index 20a36bd30..7c0cfe8dc 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaCreatePlanVersionParamsTest.kt @@ -64,9 +64,84 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -111,6 +186,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -185,9 +261,86 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -232,6 +385,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -311,9 +465,88 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -360,6 +593,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -434,9 +668,89 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -483,6 +797,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -551,9 +866,84 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -598,6 +988,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -676,9 +1067,86 @@ internal class BetaCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice.builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -723,6 +1191,7 @@ internal class BetaCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt index d24073fbd..9b4da267d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BetaExternalPlanIdCreatePlanVersionParamsTest.kt @@ -64,9 +64,91 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -111,6 +193,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -185,9 +268,92 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -232,6 +398,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -315,9 +482,94 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -364,6 +616,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -438,9 +691,94 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -487,6 +825,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -555,9 +894,91 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -602,6 +1023,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -680,9 +1102,92 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -727,6 +1232,7 @@ internal class BetaExternalPlanIdCreatePlanVersionParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt index 34ac805a9..8faa3e42b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTest.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -45,6 +46,11 @@ internal class BillableMetricTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() assertThat(billableMetric.id()).isEqualTo("id") @@ -79,6 +85,12 @@ internal class BillableMetricTest { ) assertThat(billableMetric.name()).isEqualTo("name") assertThat(billableMetric.status()).isEqualTo(BillableMetric.Status.ACTIVE) + assertThat(billableMetric.parameterDefinitions().getOrNull()) + .containsExactly( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test @@ -116,6 +128,11 @@ internal class BillableMetricTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val roundtrippedBillableMetric = diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt index a013bd44b..3f835db3b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ChangedSubscriptionResourcesTest.kt @@ -303,6 +303,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -331,6 +332,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -394,6 +396,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -779,6 +788,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -807,6 +817,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -870,6 +881,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1256,6 +1274,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1281,6 +1300,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1339,6 +1359,13 @@ internal class ChangedSubscriptionResourcesTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1713,6 +1740,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1738,6 +1766,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1796,6 +1825,13 @@ internal class ChangedSubscriptionResourcesTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2196,6 +2232,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2224,6 +2261,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2287,6 +2325,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2672,6 +2717,7 @@ internal class ChangedSubscriptionResourcesTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2700,6 +2746,7 @@ internal class ChangedSubscriptionResourcesTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2763,6 +2810,13 @@ internal class ChangedSubscriptionResourcesTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt new file mode 100644 index 000000000..a25129148 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditBlockListInvoicesParamsTest { + + @Test + fun create() { + CreditBlockListInvoicesParams.builder().blockId("block_id").build() + } + + @Test + fun pathParams() { + val params = CreditBlockListInvoicesParams.builder().blockId("block_id").build() + + assertThat(params._pathParam(0)).isEqualTo("block_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt new file mode 100644 index 000000000..6f30c53ee --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockListInvoicesResponseTest.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditBlockListInvoicesResponseTest { + + @Test + fun create() { + val creditBlockListInvoicesResponse = + CreditBlockListInvoicesResponse.builder() + .block( + CreditBlockListInvoicesResponse.Block.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CreditBlockListInvoicesResponse.Block.Filter.builder() + .field(CreditBlockListInvoicesResponse.Block.Filter.Field.PRICE_ID) + .operator( + CreditBlockListInvoicesResponse.Block.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .maximumInitialBalance(0.0) + .metadata( + CreditBlockListInvoicesResponse.Block.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .status(CreditBlockListInvoicesResponse.Block.Status.ACTIVE) + .build() + ) + .addInvoice( + CreditBlockListInvoicesResponse.Invoice.builder() + .id("id") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceNumber("invoice_number") + .status(CreditBlockListInvoicesResponse.Invoice.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .build() + ) + .build() + + assertThat(creditBlockListInvoicesResponse.block()) + .isEqualTo( + CreditBlockListInvoicesResponse.Block.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CreditBlockListInvoicesResponse.Block.Filter.builder() + .field(CreditBlockListInvoicesResponse.Block.Filter.Field.PRICE_ID) + .operator( + CreditBlockListInvoicesResponse.Block.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .maximumInitialBalance(0.0) + .metadata( + CreditBlockListInvoicesResponse.Block.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .status(CreditBlockListInvoicesResponse.Block.Status.ACTIVE) + .build() + ) + assertThat(creditBlockListInvoicesResponse.invoices()) + .containsExactly( + CreditBlockListInvoicesResponse.Invoice.builder() + .id("id") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceNumber("invoice_number") + .status(CreditBlockListInvoicesResponse.Invoice.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val creditBlockListInvoicesResponse = + CreditBlockListInvoicesResponse.builder() + .block( + CreditBlockListInvoicesResponse.Block.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFilter( + CreditBlockListInvoicesResponse.Block.Filter.builder() + .field(CreditBlockListInvoicesResponse.Block.Filter.Field.PRICE_ID) + .operator( + CreditBlockListInvoicesResponse.Block.Filter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .maximumInitialBalance(0.0) + .metadata( + CreditBlockListInvoicesResponse.Block.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .status(CreditBlockListInvoicesResponse.Block.Status.ACTIVE) + .build() + ) + .addInvoice( + CreditBlockListInvoicesResponse.Invoice.builder() + .id("id") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceNumber("invoice_number") + .status(CreditBlockListInvoicesResponse.Invoice.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .build() + ) + .build() + + val roundtrippedCreditBlockListInvoicesResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(creditBlockListInvoicesResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCreditBlockListInvoicesResponse) + .isEqualTo(creditBlockListInvoicesResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt index 68c2b96c9..364ef830f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditBlockRetrieveResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -26,6 +27,11 @@ internal class CreditBlockRetrieveResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CreditBlockRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CreditBlockRetrieveResponse.Status.ACTIVE) .build() @@ -45,6 +51,12 @@ internal class CreditBlockRetrieveResponseTest { .build() ) assertThat(creditBlockRetrieveResponse.maximumInitialBalance()).contains(0.0) + assertThat(creditBlockRetrieveResponse.metadata()) + .isEqualTo( + CreditBlockRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(creditBlockRetrieveResponse.perUnitCostBasis()).contains("per_unit_cost_basis") assertThat(creditBlockRetrieveResponse.status()) .isEqualTo(CreditBlockRetrieveResponse.Status.ACTIVE) @@ -67,6 +79,11 @@ internal class CreditBlockRetrieveResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CreditBlockRetrieveResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CreditBlockRetrieveResponse.Status.ACTIVE) .build() 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 390cc855b..1ed44b789 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 @@ -76,6 +76,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -104,6 +105,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -167,6 +169,13 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -238,6 +247,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -263,6 +273,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -321,6 +332,13 @@ internal class CustomerCostListByExternalIdResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -403,6 +421,7 @@ internal class CustomerCostListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -431,6 +450,7 @@ internal class CustomerCostListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -494,6 +514,13 @@ internal class CustomerCostListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_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 c27926b62..4dfcd2a3b 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 @@ -76,6 +76,7 @@ internal class CustomerCostListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -104,6 +105,7 @@ internal class CustomerCostListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -167,6 +169,13 @@ internal class CustomerCostListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -238,6 +247,7 @@ internal class CustomerCostListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -263,6 +273,7 @@ internal class CustomerCostListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -321,6 +332,13 @@ internal class CustomerCostListResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -403,6 +421,7 @@ internal class CustomerCostListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -431,6 +450,7 @@ internal class CustomerCostListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -494,6 +514,13 @@ internal class CustomerCostListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_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 7de2acc43..da5c2b48c 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 @@ -19,7 +19,7 @@ internal class CustomerCreateParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -61,6 +61,7 @@ internal class CustomerCreateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -109,7 +110,7 @@ internal class CustomerCreateParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -151,6 +152,7 @@ internal class CustomerCreateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -197,7 +199,7 @@ internal class CustomerCreateParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -243,6 +245,7 @@ internal class CustomerCreateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .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 8d29cb30a..1283ee12c 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 @@ -47,6 +47,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -115,6 +116,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -169,6 +171,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponseTest.kt index 0c54e65de..4ac536cf6 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 @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -272,6 +273,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -335,6 +337,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -690,6 +699,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -719,6 +729,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -786,6 +797,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) 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 0cf4b256e..6ece3389c 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 @@ -41,6 +41,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -104,6 +105,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -152,6 +154,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponseTest.kt index 7c3bc0908..b39d27a5d 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 @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -272,6 +273,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -335,6 +337,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -689,6 +698,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -718,6 +728,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -785,6 +796,13 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) 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 02d6d0a49..7a16647f3 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 @@ -262,6 +262,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -293,6 +294,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -367,6 +369,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -734,6 +743,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -765,6 +775,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -839,6 +850,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1209,6 +1227,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1240,6 +1259,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1314,6 +1334,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) 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 bb3293e9a..1cf709a68 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 @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -272,6 +273,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -335,6 +337,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -689,6 +698,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -718,6 +728,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -785,6 +796,13 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) 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 d58df0af6..0918738c1 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 @@ -262,6 +262,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -293,6 +294,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -367,6 +369,13 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -734,6 +743,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -765,6 +775,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -839,6 +850,13 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1209,6 +1227,7 @@ internal class CustomerCreditLedgerListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1240,6 +1259,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1314,6 +1334,13 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) 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 9d7f24e7b..dee3993f3 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 @@ -244,6 +244,7 @@ internal class CustomerCreditLedgerListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -272,6 +273,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -335,6 +337,13 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -689,6 +698,7 @@ internal class CustomerCreditLedgerListResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -718,6 +728,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -785,6 +796,13 @@ internal class CustomerCreditLedgerListResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt index add48b6d5..b52a00271 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -30,6 +31,11 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() @@ -56,6 +62,11 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() @@ -85,6 +96,11 @@ internal class CustomerCreditListByExternalIdPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt index c02f88add..a6ee7c823 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParamsTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,6 +15,10 @@ internal class CustomerCreditListByExternalIdParamsTest { .externalCustomerId("external_customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -38,6 +43,10 @@ internal class CustomerCreditListByExternalIdParamsTest { .externalCustomerId("external_customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -49,6 +58,10 @@ internal class CustomerCreditListByExternalIdParamsTest { QueryParams.builder() .put("currency", "currency") .put("cursor", "cursor") + .put("effective_date[gt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[gte]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lte]", "2019-12-27T18:11:19.117Z") .put("include_all_blocks", "true") .put("limit", "1") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt index ad06a474d..a1b21ef8e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -26,6 +27,11 @@ internal class CustomerCreditListByExternalIdResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() @@ -45,6 +51,12 @@ internal class CustomerCreditListByExternalIdResponseTest { .build() ) assertThat(customerCreditListByExternalIdResponse.maximumInitialBalance()).contains(0.0) + assertThat(customerCreditListByExternalIdResponse.metadata()) + .isEqualTo( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(customerCreditListByExternalIdResponse.perUnitCostBasis()) .contains("per_unit_cost_basis") assertThat(customerCreditListByExternalIdResponse.status()) @@ -68,6 +80,11 @@ internal class CustomerCreditListByExternalIdResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListByExternalIdResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt index 86c3c5fce..6164150d2 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListPageResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -28,6 +29,11 @@ internal class CustomerCreditListPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() @@ -52,6 +58,11 @@ internal class CustomerCreditListPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() @@ -79,6 +90,11 @@ internal class CustomerCreditListPageResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt index 35a23e2e9..63dceb213 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListParamsTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.withorb.api.core.http.QueryParams +import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,6 +15,10 @@ internal class CustomerCreditListParamsTest { .customerId("customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -35,6 +40,10 @@ internal class CustomerCreditListParamsTest { .customerId("customer_id") .currency("currency") .cursor("cursor") + .effectiveDateGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveDateLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .includeAllBlocks(true) .limit(1L) .build() @@ -46,6 +55,10 @@ internal class CustomerCreditListParamsTest { QueryParams.builder() .put("currency", "currency") .put("cursor", "cursor") + .put("effective_date[gt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[gte]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lt]", "2019-12-27T18:11:19.117Z") + .put("effective_date[lte]", "2019-12-27T18:11:19.117Z") .put("include_all_blocks", "true") .put("limit", "1") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt index bb1390080..c0f782d24 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -26,6 +27,11 @@ internal class CustomerCreditListResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() @@ -45,6 +51,12 @@ internal class CustomerCreditListResponseTest { .build() ) assertThat(customerCreditListResponse.maximumInitialBalance()).contains(0.0) + assertThat(customerCreditListResponse.metadata()) + .isEqualTo( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(customerCreditListResponse.perUnitCostBasis()).contains("per_unit_cost_basis") assertThat(customerCreditListResponse.status()) .isEqualTo(CustomerCreditListResponse.Status.ACTIVE) @@ -67,6 +79,11 @@ internal class CustomerCreditListResponseTest { .build() ) .maximumInitialBalance(0.0) + .metadata( + CustomerCreditListResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .status(CustomerCreditListResponse.Status.ACTIVE) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt index 94a0f1744..c966844ef 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerListPageResponseTest.kt @@ -107,6 +107,7 @@ internal class CustomerListPageResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -213,6 +214,7 @@ internal class CustomerListPageResponseTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -324,6 +326,7 @@ internal class CustomerListPageResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt index 18a41e3ca..3cdc84ae7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt @@ -103,6 +103,7 @@ internal class CustomerTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -206,6 +207,7 @@ internal class CustomerTest { .providerType( Customer.PaymentConfiguration.PaymentProvider.ProviderType.STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -308,6 +310,7 @@ internal class CustomerTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("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 ec6681489..2f9a346f2 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 @@ -18,7 +18,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -64,6 +64,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -119,7 +120,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -165,6 +166,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -208,7 +210,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -258,6 +260,7 @@ internal class CustomerUpdateByExternalIdParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .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 ff7d893f7..9af4d7f13 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 @@ -18,7 +18,7 @@ internal class CustomerUpdateParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -62,6 +62,7 @@ internal class CustomerUpdateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -117,7 +118,7 @@ internal class CustomerUpdateParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -161,6 +162,7 @@ internal class CustomerUpdateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -204,7 +206,7 @@ internal class CustomerUpdateParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -252,6 +254,7 @@ internal class CustomerUpdateParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt index e432581b5..2b1e30618 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/IncrementLedgerEntryTest.kt @@ -241,6 +241,7 @@ internal class IncrementLedgerEntryTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -269,6 +270,7 @@ internal class IncrementLedgerEntryTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -332,6 +334,13 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -660,6 +669,7 @@ internal class IncrementLedgerEntryTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -685,6 +695,7 @@ internal class IncrementLedgerEntryTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -743,6 +754,13 @@ internal class IncrementLedgerEntryTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1080,6 +1098,7 @@ internal class IncrementLedgerEntryTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1108,6 +1127,7 @@ internal class IncrementLedgerEntryTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1171,6 +1191,13 @@ internal class IncrementLedgerEntryTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt index 20399ca1d..0da3b37e3 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceCreateParamsTest.kt @@ -28,6 +28,7 @@ internal class InvoiceCreateParamsTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -77,6 +78,7 @@ internal class InvoiceCreateParamsTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -124,6 +126,7 @@ internal class InvoiceCreateParamsTest { ) .build() ) + assertThat(body.autoCollection()).contains(true) assertThat(body.customerId()).contains("4khy3nwzktxv7") assertThat(body.discount()) .contains( 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 7b746db93..53a8ffe9b 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 @@ -186,6 +186,7 @@ internal class InvoiceFetchUpcomingResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -209,6 +210,7 @@ internal class InvoiceFetchUpcomingResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -265,6 +267,13 @@ internal class InvoiceFetchUpcomingResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -556,6 +565,7 @@ internal class InvoiceFetchUpcomingResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -577,6 +587,7 @@ internal class InvoiceFetchUpcomingResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -633,6 +644,13 @@ internal class InvoiceFetchUpcomingResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -928,6 +946,7 @@ internal class InvoiceFetchUpcomingResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -951,6 +970,7 @@ internal class InvoiceFetchUpcomingResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1007,6 +1027,13 @@ internal class InvoiceFetchUpcomingResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt new file mode 100644 index 000000000..2a52476ca --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryParamsTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvoiceIssueSummaryParamsTest { + + @Test + fun create() { + InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").synchronous(true).build() + } + + @Test + fun pathParams() { + val params = InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").build() + + assertThat(params._pathParam(0)).isEqualTo("invoice_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").synchronous(true).build() + + val body = params._body() + + assertThat(body.synchronous()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = InvoiceIssueSummaryParams.builder().invoiceId("invoice_id").build() + + val body = params._body() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt new file mode 100644 index 000000000..507c3eeaf --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceIssueSummaryResponseTest.kt @@ -0,0 +1,401 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvoiceIssueSummaryResponseTest { + + @Test + fun create() { + val invoiceIssueSummaryResponse = + InvoiceIssueSummaryResponse.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + InvoiceIssueSummaryResponse.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .billingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + InvoiceIssueSummaryResponse.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CreditNoteTiny.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) + .startingBalance("33.00") + .type(InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + CustomerTaxId.builder() + .country(CustomerTaxId.Country.AD) + .type(CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + .invoiceSource(InvoiceIssueSummaryResponse.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memo("memo") + .metadata( + InvoiceIssueSummaryResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + InvoiceIssueSummaryResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceIssueSummaryResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(InvoiceIssueSummaryResponse.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + + assertThat(invoiceIssueSummaryResponse.id()).isEqualTo("id") + assertThat(invoiceIssueSummaryResponse.amountDue()).isEqualTo("8.00") + assertThat(invoiceIssueSummaryResponse.autoCollection()) + .isEqualTo( + InvoiceIssueSummaryResponse.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(invoiceIssueSummaryResponse.billingAddress()) + .contains( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(invoiceIssueSummaryResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + assertThat(invoiceIssueSummaryResponse.creditNotes()) + .containsExactly( + InvoiceIssueSummaryResponse.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + assertThat(invoiceIssueSummaryResponse.currency()).isEqualTo("USD") + assertThat(invoiceIssueSummaryResponse.customer()) + .isEqualTo( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + assertThat(invoiceIssueSummaryResponse.customerBalanceTransactions()) + .containsExactly( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CreditNoteTiny.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) + .startingBalance("33.00") + .type(InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + assertThat(invoiceIssueSummaryResponse.customerTaxId()) + .contains( + CustomerTaxId.builder() + .country(CustomerTaxId.Country.AD) + .type(CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + assertThat(invoiceIssueSummaryResponse.dueDate()) + .contains(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + assertThat(invoiceIssueSummaryResponse.eligibleToIssueAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.hostedInvoiceUrl()).contains("hosted_invoice_url") + assertThat(invoiceIssueSummaryResponse.invoiceDate()) + .isEqualTo(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + assertThat(invoiceIssueSummaryResponse.invoiceNumber()).isEqualTo("JYEFHK-00001") + assertThat(invoiceIssueSummaryResponse.invoicePdf()) + .contains("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + assertThat(invoiceIssueSummaryResponse.invoiceSource()) + .isEqualTo(InvoiceIssueSummaryResponse.InvoiceSource.SUBSCRIPTION) + assertThat(invoiceIssueSummaryResponse.issueFailedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.issuedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.memo()).contains("memo") + assertThat(invoiceIssueSummaryResponse.metadata()) + .isEqualTo( + InvoiceIssueSummaryResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(invoiceIssueSummaryResponse.paidAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.paymentAttempts()) + .containsExactly( + InvoiceIssueSummaryResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceIssueSummaryResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .succeeded(true) + .build() + ) + assertThat(invoiceIssueSummaryResponse.paymentFailedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.paymentStartedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.scheduledIssueAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.shippingAddress()) + .contains( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(invoiceIssueSummaryResponse.status()) + .isEqualTo(InvoiceIssueSummaryResponse.Status.ISSUED) + assertThat(invoiceIssueSummaryResponse.subscription()) + .contains(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + assertThat(invoiceIssueSummaryResponse.syncFailedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.total()).isEqualTo("8.00") + assertThat(invoiceIssueSummaryResponse.voidedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceIssueSummaryResponse.willAutoIssue()).isEqualTo(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val invoiceIssueSummaryResponse = + InvoiceIssueSummaryResponse.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + InvoiceIssueSummaryResponse.AutoCollection.builder() + .enabled(true) + .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .numAttempts(0L) + .previouslyAttemptedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .billingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .addCreditNote( + InvoiceIssueSummaryResponse.CreditNote.builder() + .id("id") + .creditNoteNumber("credit_note_number") + .memo("memo") + .reason("reason") + .total("total") + .type("type") + .voidedAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .build() + ) + .currency("USD") + .customer( + CustomerMinified.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.builder() + .id("cgZa3SXcsPTVyC4Y") + .action( + InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Action + .APPLIED_TO_INVOICE + ) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CreditNoteTiny.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice(InvoiceTiny.builder().id("gXcsPTVyC4YZa3Sc").build()) + .startingBalance("33.00") + .type(InvoiceIssueSummaryResponse.CustomerBalanceTransaction.Type.INCREMENT) + .build() + ) + .customerTaxId( + CustomerTaxId.builder() + .country(CustomerTaxId.Country.AD) + .type(CustomerTaxId.Type.AD_NRT) + .value("value") + .build() + ) + .dueDate(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + .eligibleToIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hostedInvoiceUrl("hosted_invoice_url") + .invoiceDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + .invoiceNumber("JYEFHK-00001") + .invoicePdf("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + .invoiceSource(InvoiceIssueSummaryResponse.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memo("memo") + .metadata( + InvoiceIssueSummaryResponse.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + InvoiceIssueSummaryResponse.PaymentAttempt.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider( + InvoiceIssueSummaryResponse.PaymentAttempt.PaymentProvider.STRIPE + ) + .paymentProviderId("payment_provider_id") + .receiptPdf( + "https://assets.withorb.com/receipt/rUHdhmg45vY45DX/qEAeuYePaphGMdFb" + ) + .succeeded(true) + .build() + ) + .paymentFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .shippingAddress( + Address.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(InvoiceIssueSummaryResponse.Status.ISSUED) + .subscription(SubscriptionMinified.builder().id("VDGsT23osdLb84KD").build()) + .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("8.00") + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .willAutoIssue(true) + .build() + + val roundtrippedInvoiceIssueSummaryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invoiceIssueSummaryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvoiceIssueSummaryResponse).isEqualTo(invoiceIssueSummaryResponse) + } +} 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 aaba0feb6..2bfca8c89 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 @@ -87,6 +87,7 @@ internal class InvoiceLineItemCreateResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -108,6 +109,7 @@ internal class InvoiceLineItemCreateResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -161,6 +163,13 @@ internal class InvoiceLineItemCreateResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -266,6 +275,7 @@ internal class InvoiceLineItemCreateResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -287,6 +297,7 @@ internal class InvoiceLineItemCreateResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -340,6 +351,13 @@ internal class InvoiceLineItemCreateResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -451,6 +469,7 @@ internal class InvoiceLineItemCreateResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -472,6 +491,7 @@ internal class InvoiceLineItemCreateResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -525,6 +545,13 @@ internal class InvoiceLineItemCreateResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) 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 d29aa1314..1fda367ed 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 @@ -205,6 +205,7 @@ internal class InvoiceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -233,6 +234,7 @@ internal class InvoiceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -296,6 +298,13 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -586,6 +595,7 @@ internal class InvoiceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -611,6 +621,7 @@ internal class InvoiceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -669,6 +680,13 @@ internal class InvoiceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -973,6 +991,7 @@ internal class InvoiceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1001,6 +1020,7 @@ internal class InvoiceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1064,6 +1084,13 @@ internal class InvoiceListPageResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoicePayParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoicePayParamsTest.kt index 961deaa25..65bfd6f01 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoicePayParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoicePayParamsTest.kt @@ -9,15 +9,35 @@ internal class InvoicePayParamsTest { @Test fun create() { - InvoicePayParams.builder().invoiceId("invoice_id").build() + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() } @Test fun pathParams() { - val params = InvoicePayParams.builder().invoiceId("invoice_id").build() + val params = + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() assertThat(params._pathParam(0)).isEqualTo("invoice_id") // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } + + @Test + fun body() { + val params = + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() + + val body = params._body() + + assertThat(body.sharedPaymentTokenId()).isEqualTo("shared_payment_token_id") + } } 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 632b5b154..21dedbbe3 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 @@ -182,6 +182,7 @@ internal class InvoiceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -205,6 +206,7 @@ internal class InvoiceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -261,6 +263,13 @@ internal class InvoiceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -543,6 +552,7 @@ internal class InvoiceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -564,6 +574,7 @@ internal class InvoiceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -620,6 +631,13 @@ internal class InvoiceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -904,6 +922,7 @@ internal class InvoiceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -927,6 +946,7 @@ internal class InvoiceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -983,6 +1003,13 @@ internal class InvoiceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt index 5ac0a6683..f8b22c736 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceUpdateParamsTest.kt @@ -13,6 +13,7 @@ internal class InvoiceUpdateParamsTest { fun create() { InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -38,6 +39,7 @@ internal class InvoiceUpdateParamsTest { val params = InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -50,6 +52,7 @@ internal class InvoiceUpdateParamsTest { val body = params._body() + assertThat(body.autoCollection()).contains(true) assertThat(body.dueDate()) .contains(InvoiceUpdateParams.DueDate.ofDate(LocalDate.parse("2023-09-22"))) assertThat(body.invoiceDate()) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt new file mode 100644 index 000000000..6afad4000 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseCreateParamsTest { + + @Test + fun create() { + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + } + + @Test + fun body() { + val params = + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + + val body = params._body() + + assertThat(body.externalLicenseId()).isEqualTo("external_license_id") + assertThat(body.licenseTypeId()).isEqualTo("license_type_id") + assertThat(body.subscriptionId()).isEqualTo("subscription_id") + assertThat(body.endDate()).contains(LocalDate.parse("2026-01-27")) + assertThat(body.startDate()).contains(LocalDate.parse("2026-01-27")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val body = params._body() + + assertThat(body.externalLicenseId()).isEqualTo("external_license_id") + assertThat(body.licenseTypeId()).isEqualTo("license_type_id") + assertThat(body.subscriptionId()).isEqualTo("subscription_id") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt new file mode 100644 index 000000000..a2b9ff432 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseCreateResponseTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseCreateResponseTest { + + @Test + fun create() { + val licenseCreateResponse = + LicenseCreateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseCreateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseCreateResponse.id()).isEqualTo("id") + assertThat(licenseCreateResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseCreateResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseCreateResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseCreateResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseCreateResponse.status()).isEqualTo(LicenseCreateResponse.Status.ACTIVE) + assertThat(licenseCreateResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseCreateResponse = + LicenseCreateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseCreateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseCreateResponse).isEqualTo(licenseCreateResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt new file mode 100644 index 000000000..55445a395 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateParamsTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseDeactivateParamsTest { + + @Test + fun create() { + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + } + + @Test + fun pathParams() { + val params = LicenseDeactivateParams.builder().licenseId("license_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + + val body = params._body() + + assertThat(body.endDate()).contains(LocalDate.parse("2026-01-27")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = LicenseDeactivateParams.builder().licenseId("license_id").build() + + val body = params._body() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt new file mode 100644 index 000000000..15edeed91 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseDeactivateResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseDeactivateResponseTest { + + @Test + fun create() { + val licenseDeactivateResponse = + LicenseDeactivateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseDeactivateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseDeactivateResponse.id()).isEqualTo("id") + assertThat(licenseDeactivateResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseDeactivateResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseDeactivateResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseDeactivateResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseDeactivateResponse.status()) + .isEqualTo(LicenseDeactivateResponse.Status.ACTIVE) + assertThat(licenseDeactivateResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseDeactivateResponse = + LicenseDeactivateResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseDeactivateResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseDeactivateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseDeactivateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseDeactivateResponse).isEqualTo(licenseDeactivateResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt new file mode 100644 index 000000000..4d04e1783 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageParamsTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseExternalLicenseGetUsageParamsTest { + + @Test + fun create() { + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun pathParams() { + val params = + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("external_license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .put("cursor", "cursor") + .put("end_date", "2019-12-27") + .put("group_by[]", "string") + .put("limit", "1") + .put("start_date", "2019-12-27") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt new file mode 100644 index 000000000..80cf3d8dd --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseExternalLicenseGetUsageResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseExternalLicenseGetUsageResponseTest { + + @Test + fun create() { + val licenseExternalLicenseGetUsageResponse = + LicenseExternalLicenseGetUsageResponse.builder() + .addData( + LicenseExternalLicenseGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseExternalLicenseGetUsageResponse.data()) + .containsExactly( + LicenseExternalLicenseGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + assertThat(licenseExternalLicenseGetUsageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseExternalLicenseGetUsageResponse = + LicenseExternalLicenseGetUsageResponse.builder() + .addData( + LicenseExternalLicenseGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseExternalLicenseGetUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseExternalLicenseGetUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseExternalLicenseGetUsageResponse) + .isEqualTo(licenseExternalLicenseGetUsageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt new file mode 100644 index 000000000..4f9b17d8b --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListPageResponseTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseListPageResponseTest { + + @Test + fun create() { + val licenseListPageResponse = + LicenseListPageResponse.builder() + .addData( + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseListPageResponse.data()) + .containsExactly( + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + ) + assertThat(licenseListPageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseListPageResponse = + LicenseListPageResponse.builder() + .addData( + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseListPageResponse).isEqualTo(licenseListPageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt new file mode 100644 index 000000000..41c62d909 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseListParamsTest { + + @Test + fun create() { + LicenseListParams.builder() + .subscriptionId("subscription_id") + .cursor("cursor") + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .limit(1L) + .status(LicenseListParams.Status.ACTIVE) + .build() + } + + @Test + fun queryParams() { + val params = + LicenseListParams.builder() + .subscriptionId("subscription_id") + .cursor("cursor") + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .limit(1L) + .status(LicenseListParams.Status.ACTIVE) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("subscription_id", "subscription_id") + .put("cursor", "cursor") + .put("external_license_id", "external_license_id") + .put("license_type_id", "license_type_id") + .put("limit", "1") + .put("status", "active") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = LicenseListParams.builder().subscriptionId("subscription_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("subscription_id", "subscription_id").build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt new file mode 100644 index 000000000..716cdd5b4 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseListResponseTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseListResponseTest { + + @Test + fun create() { + val licenseListResponse = + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseListResponse.id()).isEqualTo("id") + assertThat(licenseListResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseListResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseListResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseListResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseListResponse.status()).isEqualTo(LicenseListResponse.Status.ACTIVE) + assertThat(licenseListResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseListResponse = + LicenseListResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseListResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseListResponse).isEqualTo(licenseListResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt new file mode 100644 index 000000000..a1c636dd4 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveByExternalIdParamsTest { + + @Test + fun create() { + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + } + + @Test + fun pathParams() { + val params = + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + assertThat(params._pathParam(0)).isEqualTo("external_license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt new file mode 100644 index 000000000..c9d7e9b26 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveByExternalIdResponseTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveByExternalIdResponseTest { + + @Test + fun create() { + val licenseRetrieveByExternalIdResponse = + LicenseRetrieveByExternalIdResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveByExternalIdResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseRetrieveByExternalIdResponse.id()).isEqualTo("id") + assertThat(licenseRetrieveByExternalIdResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveByExternalIdResponse.externalLicenseId()) + .isEqualTo("external_license_id") + assertThat(licenseRetrieveByExternalIdResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseRetrieveByExternalIdResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveByExternalIdResponse.status()) + .isEqualTo(LicenseRetrieveByExternalIdResponse.Status.ACTIVE) + assertThat(licenseRetrieveByExternalIdResponse.subscriptionId()) + .isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseRetrieveByExternalIdResponse = + LicenseRetrieveByExternalIdResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveByExternalIdResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseRetrieveByExternalIdResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseRetrieveByExternalIdResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseRetrieveByExternalIdResponse) + .isEqualTo(licenseRetrieveByExternalIdResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt new file mode 100644 index 000000000..c23771812 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveParamsTest { + + @Test + fun create() { + LicenseRetrieveParams.builder().licenseId("license_id").build() + } + + @Test + fun pathParams() { + val params = LicenseRetrieveParams.builder().licenseId("license_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt new file mode 100644 index 000000000..46bc72488 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseRetrieveResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseRetrieveResponseTest { + + @Test + fun create() { + val licenseRetrieveResponse = + LicenseRetrieveResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + assertThat(licenseRetrieveResponse.id()).isEqualTo("id") + assertThat(licenseRetrieveResponse.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveResponse.externalLicenseId()).isEqualTo("external_license_id") + assertThat(licenseRetrieveResponse.licenseTypeId()).isEqualTo("license_type_id") + assertThat(licenseRetrieveResponse.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(licenseRetrieveResponse.status()) + .isEqualTo(LicenseRetrieveResponse.Status.ACTIVE) + assertThat(licenseRetrieveResponse.subscriptionId()).isEqualTo("subscription_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseRetrieveResponse = + LicenseRetrieveResponse.builder() + .id("id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(LicenseRetrieveResponse.Status.ACTIVE) + .subscriptionId("subscription_id") + .build() + + val roundtrippedLicenseRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseRetrieveResponse).isEqualTo(licenseRetrieveResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt new file mode 100644 index 000000000..d03341e56 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeCreateParamsTest { + + @Test + fun create() { + LicenseTypeCreateParams.builder().groupingKey("x").name("x").build() + } + + @Test + fun body() { + val params = LicenseTypeCreateParams.builder().groupingKey("x").name("x").build() + + val body = params._body() + + assertThat(body.groupingKey()).isEqualTo("x") + assertThat(body.name()).isEqualTo("x") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt new file mode 100644 index 000000000..91b78f2bb --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeCreateResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeCreateResponseTest { + + @Test + fun create() { + val licenseTypeCreateResponse = + LicenseTypeCreateResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + assertThat(licenseTypeCreateResponse.id()).isEqualTo("id") + assertThat(licenseTypeCreateResponse.groupingKey()).isEqualTo("grouping_key") + assertThat(licenseTypeCreateResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeCreateResponse = + LicenseTypeCreateResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + val roundtrippedLicenseTypeCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeCreateResponse).isEqualTo(licenseTypeCreateResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt new file mode 100644 index 000000000..8462e1fb3 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListPageResponseTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeListPageResponseTest { + + @Test + fun create() { + val licenseTypeListPageResponse = + LicenseTypeListPageResponse.builder() + .addData( + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseTypeListPageResponse.data()) + .containsExactly( + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + assertThat(licenseTypeListPageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeListPageResponse = + LicenseTypeListPageResponse.builder() + .addData( + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseTypeListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeListPageResponse).isEqualTo(licenseTypeListPageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt new file mode 100644 index 000000000..92c42e709 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeListParamsTest { + + @Test + fun create() { + LicenseTypeListParams.builder().cursor("cursor").limit(1L).build() + } + + @Test + fun queryParams() { + val params = LicenseTypeListParams.builder().cursor("cursor").limit(1L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("limit", "1").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = LicenseTypeListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt new file mode 100644 index 000000000..0c5c783eb --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeListResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeListResponseTest { + + @Test + fun create() { + val licenseTypeListResponse = + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + assertThat(licenseTypeListResponse.id()).isEqualTo("id") + assertThat(licenseTypeListResponse.groupingKey()).isEqualTo("grouping_key") + assertThat(licenseTypeListResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeListResponse = + LicenseTypeListResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + val roundtrippedLicenseTypeListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeListResponse).isEqualTo(licenseTypeListResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt new file mode 100644 index 000000000..e1d93b327 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeRetrieveParamsTest { + + @Test + fun create() { + LicenseTypeRetrieveParams.builder().licenseTypeId("license_type_id").build() + } + + @Test + fun pathParams() { + val params = LicenseTypeRetrieveParams.builder().licenseTypeId("license_type_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_type_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt new file mode 100644 index 000000000..8e7235789 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseTypeRetrieveResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseTypeRetrieveResponseTest { + + @Test + fun create() { + val licenseTypeRetrieveResponse = + LicenseTypeRetrieveResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + assertThat(licenseTypeRetrieveResponse.id()).isEqualTo("id") + assertThat(licenseTypeRetrieveResponse.groupingKey()).isEqualTo("grouping_key") + assertThat(licenseTypeRetrieveResponse.name()).isEqualTo("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseTypeRetrieveResponse = + LicenseTypeRetrieveResponse.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + + val roundtrippedLicenseTypeRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseTypeRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseTypeRetrieveResponse).isEqualTo(licenseTypeRetrieveResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt new file mode 100644 index 000000000..d9967a76c --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetAllUsageParamsTest { + + @Test + fun create() { + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun queryParams() { + val params = + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .put("cursor", "cursor") + .put("end_date", "2019-12-27") + .put("group_by[]", "string") + .put("limit", "1") + .put("start_date", "2019-12-27") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("license_type_id", "license_type_id") + .put("subscription_id", "subscription_id") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt new file mode 100644 index 000000000..041366f38 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetAllUsageResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetAllUsageResponseTest { + + @Test + fun create() { + val licenseUsageGetAllUsageResponse = + LicenseUsageGetAllUsageResponse.builder() + .addData( + LicenseUsageGetAllUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseUsageGetAllUsageResponse.data()) + .containsExactly( + LicenseUsageGetAllUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + assertThat(licenseUsageGetAllUsageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseUsageGetAllUsageResponse = + LicenseUsageGetAllUsageResponse.builder() + .addData( + LicenseUsageGetAllUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseUsageGetAllUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseUsageGetAllUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseUsageGetAllUsageResponse) + .isEqualTo(licenseUsageGetAllUsageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt new file mode 100644 index 000000000..b14f6766e --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageParamsTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetUsageParamsTest { + + @Test + fun create() { + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun pathParams() { + val params = LicenseUsageGetUsageParams.builder().licenseId("license_id").build() + + assertThat(params._pathParam(0)).isEqualTo("license_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("cursor", "cursor") + .put("end_date", "2019-12-27") + .put("group_by[]", "string") + .put("limit", "1") + .put("start_date", "2019-12-27") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = LicenseUsageGetUsageParams.builder().licenseId("license_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt new file mode 100644 index 000000000..19893d26e --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/LicenseUsageGetUsageResponseTest.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.jsonMapper +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LicenseUsageGetUsageResponseTest { + + @Test + fun create() { + val licenseUsageGetUsageResponse = + LicenseUsageGetUsageResponse.builder() + .addData( + LicenseUsageGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + assertThat(licenseUsageGetUsageResponse.data()) + .containsExactly( + LicenseUsageGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + assertThat(licenseUsageGetUsageResponse.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val licenseUsageGetUsageResponse = + LicenseUsageGetUsageResponse.builder() + .addData( + LicenseUsageGetUsageResponse.Data.builder() + .allocatedCredits(0.0) + .consumedCredits(0.0) + .endDate(LocalDate.parse("2019-12-27")) + .licenseTypeId("license_type_id") + .pricingUnit("pricing_unit") + .remainingCredits(0.0) + .startDate(LocalDate.parse("2019-12-27")) + .subscriptionId("subscription_id") + .allocationEligibleCredits(0.0) + .externalLicenseId("external_license_id") + .licenseId("license_id") + .sharedPoolCredits(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + + val roundtrippedLicenseUsageGetUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(licenseUsageGetUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLicenseUsageGetUsageResponse).isEqualTo(licenseUsageGetUsageResponse) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt index 4f47b1738..ab3a67472 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricListPageResponseTest.kt @@ -47,6 +47,11 @@ internal class MetricListPageResponseTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .paginationMetadata( @@ -87,6 +92,11 @@ internal class MetricListPageResponseTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(metricListPageResponse.paginationMetadata()) @@ -130,6 +140,11 @@ internal class MetricListPageResponseTest { ) .name("name") .status(BillableMetric.Status.ACTIVE) + .addParameterDefinition( + BillableMetric.ParameterDefinition.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .paginationMetadata( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt index 060ea7c3f..c0491fc8a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionTest.kt @@ -151,6 +151,7 @@ internal class MutatedSubscriptionTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -421,6 +422,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -444,6 +446,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -500,6 +503,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -584,6 +594,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -607,6 +618,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -663,10 +675,22 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1000,6 +1024,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1031,6 +1056,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1105,6 +1131,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1521,6 +1554,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1552,6 +1586,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1626,6 +1661,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1876,6 +1918,7 @@ internal class MutatedSubscriptionTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -2149,6 +2192,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2170,6 +2214,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2226,6 +2271,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2305,6 +2357,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2326,6 +2379,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2382,10 +2436,22 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(mutatedSubscription.redeemedCoupon()) @@ -2704,6 +2770,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2733,6 +2800,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2800,6 +2868,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3193,6 +3268,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3222,6 +3298,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3289,6 +3366,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3541,6 +3625,7 @@ internal class MutatedSubscriptionTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -3811,6 +3896,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3834,6 +3920,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3890,6 +3977,13 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -3974,6 +4068,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3997,6 +4092,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4053,10 +4149,22 @@ internal class MutatedSubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -4390,6 +4498,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4421,6 +4530,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4495,6 +4605,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4911,6 +5028,7 @@ internal class MutatedSubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4942,6 +5060,7 @@ internal class MutatedSubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5016,6 +5135,13 @@ internal class MutatedSubscriptionTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationTest.kt index 854353fe0..0be67787a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationTest.kt @@ -17,7 +17,7 @@ internal class NewAccountingSyncConfigurationTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -27,7 +27,7 @@ internal class NewAccountingSyncConfigurationTest { .containsExactly( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) assertThat(newAccountingSyncConfiguration.excluded()).contains(true) @@ -41,7 +41,7 @@ internal class NewAccountingSyncConfigurationTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt index 951ee45e1..4c03bf344 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceTest.kt @@ -3,6 +3,7 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.JsonValue import com.withorb.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -32,6 +33,12 @@ internal class NewAllocationPriceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() @@ -55,6 +62,13 @@ internal class NewAllocationPriceTest { .build() ) assertThat(newAllocationPrice.itemId()).contains("item_id") + assertThat(newAllocationPrice.licenseTypeId()).contains("license_type_id") + assertThat(newAllocationPrice.metadata()) + .contains( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(newAllocationPrice.perUnitCostBasis()).contains("per_unit_cost_basis") } @@ -81,6 +95,12 @@ internal class NewAllocationPriceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt index 45faf3712..e69f6bbd5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkPriceTest.kt @@ -54,6 +54,7 @@ internal class NewFloatingBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -111,6 +112,7 @@ internal class NewFloatingBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingBulkPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingBulkPrice.metadata()) .contains( NewFloatingBulkPrice.Metadata.builder() @@ -164,6 +166,7 @@ internal class NewFloatingBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt index 340da8294..950a731be 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingBulkWithProrationPriceTest.kt @@ -63,6 +63,7 @@ internal class NewFloatingBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class NewFloatingBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingBulkWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingBulkWithProrationPrice.metadata()) .contains( NewFloatingBulkWithProrationPrice.Metadata.builder() @@ -197,6 +199,7 @@ internal class NewFloatingBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt index 8952c2abc..95778c09c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingCumulativeGroupedBulkPriceTest.kt @@ -61,6 +61,7 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -131,6 +132,8 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingCumulativeGroupedBulkPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingCumulativeGroupedBulkPrice.metadata()) .contains( NewFloatingCumulativeGroupedBulkPrice.Metadata.builder() @@ -191,6 +194,7 @@ internal class NewFloatingCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt index 094d0a60f..5b424a3f1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewFloatingGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -117,6 +118,7 @@ internal class NewFloatingGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingGroupedAllocationPrice.metadata()) .contains( NewFloatingGroupedAllocationPrice.Metadata.builder() @@ -170,6 +172,7 @@ internal class NewFloatingGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt index 66160bb01..b458fdd74 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingGroupedTieredPackagePrice.metadata()) .contains( NewFloatingGroupedTieredPackagePrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewFloatingGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt index 8676809fb..c7d94a269 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedTieredPriceTest.kt @@ -64,6 +64,7 @@ internal class NewFloatingGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class NewFloatingGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingGroupedTieredPrice.metadata()) .contains( NewFloatingGroupedTieredPrice.Metadata.builder() @@ -198,6 +200,7 @@ internal class NewFloatingGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt index c72fd666a..b3e4acb16 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithMeteredMinimumPriceTest.kt @@ -76,6 +76,7 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -158,6 +159,8 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedWithMeteredMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingGroupedWithMeteredMinimumPrice.metadata()) .contains( NewFloatingGroupedWithMeteredMinimumPrice.Metadata.builder() @@ -233,6 +236,7 @@ internal class NewFloatingGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt index 5c5a996cc..16d466ec6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingGroupedWithProratedMinimumPriceTest.kt @@ -58,6 +58,7 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,8 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingGroupedWithProratedMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingGroupedWithProratedMinimumPrice.metadata()) .contains( NewFloatingGroupedWithProratedMinimumPrice.Metadata.builder() @@ -181,6 +184,7 @@ internal class NewFloatingGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt index 3f1972cf2..2796b1325 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixPriceTest.kt @@ -59,6 +59,7 @@ internal class NewFloatingMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -125,6 +126,7 @@ internal class NewFloatingMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMatrixPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingMatrixPrice.metadata()) .contains( NewFloatingMatrixPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewFloatingMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt index 0755eeb7a..ba8869d67 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithAllocationPriceTest.kt @@ -60,6 +60,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -129,6 +130,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMatrixWithAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingMatrixWithAllocationPrice.metadata()) .contains( NewFloatingMatrixWithAllocationPrice.Metadata.builder() @@ -188,6 +190,7 @@ internal class NewFloatingMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt index a611895a2..21bc3c988 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMatrixWithDisplayNamePriceTest.kt @@ -61,6 +61,7 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,8 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMatrixWithDisplayNamePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingMatrixWithDisplayNamePrice.metadata()) .contains( NewFloatingMatrixWithDisplayNamePrice.Metadata.builder() @@ -190,6 +193,7 @@ internal class NewFloatingMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt index 45b67882e..ae963a1bd 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMaxGroupTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,8 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMaxGroupTieredPackagePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingMaxGroupTieredPackagePrice.metadata()) .contains( NewFloatingMaxGroupTieredPackagePrice.Metadata.builder() @@ -209,6 +212,7 @@ internal class NewFloatingMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt index dbd604263..8d249608f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingMinimumCompositePriceTest.kt @@ -53,6 +53,7 @@ internal class NewFloatingMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewFloatingMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingMinimumCompositePrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingMinimumCompositePrice.metadata()) .contains( NewFloatingMinimumCompositePrice.Metadata.builder() @@ -166,6 +168,7 @@ internal class NewFloatingMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt index ed37b52ea..507d11a43 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackagePriceTest.kt @@ -50,6 +50,7 @@ internal class NewFloatingPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -107,6 +108,7 @@ internal class NewFloatingPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingPackagePrice.metadata()) .contains( NewFloatingPackagePrice.Metadata.builder() @@ -156,6 +158,7 @@ internal class NewFloatingPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt index ead452761..232023769 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingPackageWithAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewFloatingPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -117,6 +118,8 @@ internal class NewFloatingPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingPackageWithAllocationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingPackageWithAllocationPrice.metadata()) .contains( NewFloatingPackageWithAllocationPrice.Metadata.builder() @@ -170,6 +173,7 @@ internal class NewFloatingPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt index ff18721f6..379c10ef8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithTieredPricingPriceTest.kt @@ -86,6 +86,7 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -186,6 +187,8 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingScalableMatrixWithTieredPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingScalableMatrixWithTieredPricingPrice.metadata()) .contains( NewFloatingScalableMatrixWithTieredPricingPrice.Metadata.builder() @@ -271,6 +274,7 @@ internal class NewFloatingScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt index 202827aa1..2a83859f0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingScalableMatrixWithUnitPricingPriceTest.kt @@ -38,6 +38,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -70,6 +71,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -105,6 +107,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -150,6 +153,8 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingScalableMatrixWithUnitPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingScalableMatrixWithUnitPricingPrice.metadata()) .contains( NewFloatingScalableMatrixWithUnitPricingPrice.Metadata.builder() @@ -187,6 +192,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -219,6 +225,7 @@ internal class NewFloatingScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt index 848114418..e3361e05c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingThresholdTotalAmountPriceTest.kt @@ -68,6 +68,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -145,6 +146,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingThresholdTotalAmountPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingThresholdTotalAmountPrice.metadata()) .contains( NewFloatingThresholdTotalAmountPrice.Metadata.builder() @@ -212,6 +214,7 @@ internal class NewFloatingThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt index 9c48a9c9e..da537b91c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackagePriceTest.kt @@ -64,6 +64,7 @@ internal class NewFloatingTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -135,6 +136,7 @@ internal class NewFloatingTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingTieredPackagePrice.metadata()) .contains( NewFloatingTieredPackagePrice.Metadata.builder() @@ -198,6 +200,7 @@ internal class NewFloatingTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt index 35b3511b3..e371a644a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPackageWithMinimumPriceTest.kt @@ -73,6 +73,7 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -152,6 +153,8 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredPackageWithMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newFloatingTieredPackageWithMinimumPrice.metadata()) .contains( NewFloatingTieredPackageWithMinimumPrice.Metadata.builder() @@ -224,6 +227,7 @@ internal class NewFloatingTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt index 07ac87b3b..310f7efe7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredPriceTest.kt @@ -59,6 +59,7 @@ internal class NewFloatingTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -125,6 +126,7 @@ internal class NewFloatingTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingTieredPrice.metadata()) .contains( NewFloatingTieredPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewFloatingTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt index bd4fdacc9..43be9b6d7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithMinimumPriceTest.kt @@ -67,6 +67,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredWithMinimumPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingTieredWithMinimumPrice.metadata()) .contains( NewFloatingTieredWithMinimumPrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewFloatingTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt index 1769baf18..6a1f6b3e4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingTieredWithProrationPriceTest.kt @@ -58,6 +58,7 @@ internal class NewFloatingTieredWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,7 @@ internal class NewFloatingTieredWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingTieredWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingTieredWithProrationPrice.metadata()) .contains( NewFloatingTieredWithProrationPrice.Metadata.builder() @@ -181,6 +183,7 @@ internal class NewFloatingTieredWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingTieredWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt index 65938c6f0..b7d43d65c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitPriceTest.kt @@ -48,6 +48,7 @@ internal class NewFloatingUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -101,6 +102,7 @@ internal class NewFloatingUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingUnitPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingUnitPrice.metadata()) .contains( NewFloatingUnitPrice.Metadata.builder() @@ -148,6 +150,7 @@ internal class NewFloatingUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt index 081e00644..20731a8e5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithPercentPriceTest.kt @@ -53,6 +53,7 @@ internal class NewFloatingUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewFloatingUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingUnitWithPercentPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingUnitWithPercentPrice.metadata()) .contains( NewFloatingUnitWithPercentPrice.Metadata.builder() @@ -166,6 +168,7 @@ internal class NewFloatingUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt index 2e4fae2ce..8bf8e24f4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewFloatingUnitWithProrationPriceTest.kt @@ -52,6 +52,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -113,6 +114,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newFloatingUnitWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newFloatingUnitWithProrationPrice.metadata()) .contains( NewFloatingUnitWithProrationPrice.Metadata.builder() @@ -164,6 +166,7 @@ internal class NewFloatingUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt index f3f1100a7..f4412d93b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkPriceTest.kt @@ -54,6 +54,7 @@ internal class NewPlanBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -112,6 +113,7 @@ internal class NewPlanBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanBulkPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanBulkPrice.metadata()) .contains( NewPlanBulkPrice.Metadata.builder() @@ -166,6 +168,7 @@ internal class NewPlanBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt index 93f84aaf9..068932a9b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanBulkWithProrationPriceTest.kt @@ -63,6 +63,7 @@ internal class NewPlanBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -134,6 +135,7 @@ internal class NewPlanBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanBulkWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanBulkWithProrationPrice.metadata()) .contains( NewPlanBulkWithProrationPrice.Metadata.builder() @@ -197,6 +199,7 @@ internal class NewPlanBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt index 20bd1b583..85970e725 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanCumulativeGroupedBulkPriceTest.kt @@ -61,6 +61,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -131,6 +132,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanCumulativeGroupedBulkPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanCumulativeGroupedBulkPrice.metadata()) .contains( NewPlanCumulativeGroupedBulkPrice.Metadata.builder() @@ -192,6 +194,7 @@ internal class NewPlanCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt index 5ce0cab0d..058ae49ce 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewPlanGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -116,6 +117,7 @@ internal class NewPlanGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanGroupedAllocationPrice.metadata()) .contains( NewPlanGroupedAllocationPrice.Metadata.builder() @@ -170,6 +172,7 @@ internal class NewPlanGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt index a20e9666f..b126aaae1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -141,6 +142,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanGroupedTieredPackagePrice.metadata()) .contains( NewPlanGroupedTieredPackagePrice.Metadata.builder() @@ -208,6 +210,7 @@ internal class NewPlanGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt index b3d3e0785..168d14508 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedTieredPriceTest.kt @@ -64,6 +64,7 @@ internal class NewPlanGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -136,6 +137,7 @@ internal class NewPlanGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanGroupedTieredPrice.metadata()) .contains( NewPlanGroupedTieredPrice.Metadata.builder() @@ -200,6 +202,7 @@ internal class NewPlanGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt index f135d9304..149675b40 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithMeteredMinimumPriceTest.kt @@ -73,6 +73,7 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -154,6 +155,8 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedWithMeteredMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newPlanGroupedWithMeteredMinimumPrice.metadata()) .contains( NewPlanGroupedWithMeteredMinimumPrice.Metadata.builder() @@ -227,6 +230,7 @@ internal class NewPlanGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt index b237e469b..1557ae707 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanGroupedWithProratedMinimumPriceTest.kt @@ -57,6 +57,7 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -123,6 +124,8 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanGroupedWithProratedMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newPlanGroupedWithProratedMinimumPrice.metadata()) .contains( NewPlanGroupedWithProratedMinimumPrice.Metadata.builder() @@ -180,6 +183,7 @@ internal class NewPlanGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt index 789bb03b5..aba350850 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixPriceTest.kt @@ -59,6 +59,7 @@ internal class NewPlanMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,7 @@ internal class NewPlanMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMatrixPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMatrixPrice.metadata()) .contains( NewPlanMatrixPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewPlanMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt index 53233108d..ff7218f4b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithAllocationPriceTest.kt @@ -60,6 +60,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -129,6 +130,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMatrixWithAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMatrixWithAllocationPrice.metadata()) .contains( NewPlanMatrixWithAllocationPrice.Metadata.builder() @@ -189,6 +191,7 @@ internal class NewPlanMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt index 1b1327df7..ea02b00e0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMatrixWithDisplayNamePriceTest.kt @@ -60,6 +60,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMatrixWithDisplayNamePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMatrixWithDisplayNamePrice.metadata()) .contains( NewPlanMatrixWithDisplayNamePrice.Metadata.builder() @@ -190,6 +192,7 @@ internal class NewPlanMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt index 4d3661632..d4806a69e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMaxGroupTieredPackagePriceTest.kt @@ -67,6 +67,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -142,6 +143,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMaxGroupTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMaxGroupTieredPackagePrice.metadata()) .contains( NewPlanMaxGroupTieredPackagePrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewPlanMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt index d35d849ad..70e8a8285 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanMinimumCompositePriceTest.kt @@ -53,6 +53,7 @@ internal class NewPlanMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewPlanMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanMinimumCompositePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanMinimumCompositePrice.metadata()) .contains( NewPlanMinimumCompositePrice.Metadata.builder() @@ -167,6 +169,7 @@ internal class NewPlanMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt index 2b8f8db8b..9ed1c967c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackagePriceTest.kt @@ -50,6 +50,7 @@ internal class NewPlanPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -106,6 +107,7 @@ internal class NewPlanPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanPackagePrice.metadata()) .contains( NewPlanPackagePrice.Metadata.builder() @@ -156,6 +158,7 @@ internal class NewPlanPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt index 06963f176..24eb1816b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanPackageWithAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewPlanPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -118,6 +119,7 @@ internal class NewPlanPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanPackageWithAllocationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanPackageWithAllocationPrice.metadata()) .contains( NewPlanPackageWithAllocationPrice.Metadata.builder() @@ -172,6 +174,7 @@ internal class NewPlanPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt index 613d5e6f1..9e0c45e2d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithTieredPricingPriceTest.kt @@ -86,6 +86,7 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -183,6 +184,8 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanScalableMatrixWithTieredPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newPlanScalableMatrixWithTieredPricingPrice.metadata()) .contains( NewPlanScalableMatrixWithTieredPricingPrice.Metadata.builder() @@ -270,6 +273,7 @@ internal class NewPlanScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt index 83a3eb800..5634a05f8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanScalableMatrixWithUnitPricingPriceTest.kt @@ -36,6 +36,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -69,6 +70,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -102,6 +104,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -148,6 +151,8 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanScalableMatrixWithUnitPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newPlanScalableMatrixWithUnitPricingPrice.metadata()) .contains( NewPlanScalableMatrixWithUnitPricingPrice.Metadata.builder() @@ -184,6 +189,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -217,6 +223,7 @@ internal class NewPlanScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt index 90357304e..47c496502 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanThresholdTotalAmountPriceTest.kt @@ -68,6 +68,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -143,6 +144,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanThresholdTotalAmountPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanThresholdTotalAmountPrice.metadata()) .contains( NewPlanThresholdTotalAmountPrice.Metadata.builder() @@ -211,6 +213,7 @@ internal class NewPlanThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt index 35759c36d..e531bd65e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackagePriceTest.kt @@ -64,6 +64,7 @@ internal class NewPlanTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -136,6 +137,7 @@ internal class NewPlanTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanTieredPackagePrice.metadata()) .contains( NewPlanTieredPackagePrice.Metadata.builder() @@ -200,6 +202,7 @@ internal class NewPlanTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt index 7fad794b9..a5cb898d1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPackageWithMinimumPriceTest.kt @@ -70,6 +70,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredPackageWithMinimumPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanTieredPackageWithMinimumPrice.metadata()) .contains( NewPlanTieredPackageWithMinimumPrice.Metadata.builder() @@ -218,6 +220,7 @@ internal class NewPlanTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt index 5176465f5..f220a5660 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredPriceTest.kt @@ -59,6 +59,7 @@ internal class NewPlanTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -124,6 +125,7 @@ internal class NewPlanTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanTieredPrice.metadata()) .contains( NewPlanTieredPrice.Metadata.builder() @@ -183,6 +185,7 @@ internal class NewPlanTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt index 9cae1ad69..79e3574ed 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanTieredWithMinimumPriceTest.kt @@ -67,6 +67,7 @@ internal class NewPlanTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -142,6 +143,7 @@ internal class NewPlanTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanTieredWithMinimumPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanTieredWithMinimumPrice.metadata()) .contains( NewPlanTieredWithMinimumPrice.Metadata.builder() @@ -209,6 +211,7 @@ internal class NewPlanTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt index e3a650dc8..59beb2607 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitPriceTest.kt @@ -48,6 +48,7 @@ internal class NewPlanUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -102,6 +103,7 @@ internal class NewPlanUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanUnitPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanUnitPrice.metadata()) .contains( NewPlanUnitPrice.Metadata.builder() @@ -150,6 +152,7 @@ internal class NewPlanUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt index 0b4d1f7b0..c6bd0c867 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithPercentPriceTest.kt @@ -53,6 +53,7 @@ internal class NewPlanUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewPlanUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanUnitWithPercentPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanUnitWithPercentPrice.metadata()) .contains( NewPlanUnitWithPercentPrice.Metadata.builder() @@ -167,6 +169,7 @@ internal class NewPlanUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt index 0325b3841..dfa16f991 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewPlanUnitWithProrationPriceTest.kt @@ -52,6 +52,7 @@ internal class NewPlanUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -112,6 +113,7 @@ internal class NewPlanUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newPlanUnitWithProrationPrice.licenseTypeId()).contains("license_type_id") assertThat(newPlanUnitWithProrationPrice.metadata()) .contains( NewPlanUnitWithProrationPrice.Metadata.builder() @@ -164,6 +166,7 @@ internal class NewPlanUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt index 6dded0f58..94d6cf4f7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkPriceTest.kt @@ -54,6 +54,7 @@ internal class NewSubscriptionBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,7 @@ internal class NewSubscriptionBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionBulkPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionBulkPrice.metadata()) .contains( NewSubscriptionBulkPrice.Metadata.builder() @@ -168,6 +170,7 @@ internal class NewSubscriptionBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt index 86c0346bf..9fcd36023 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionBulkWithProrationPriceTest.kt @@ -65,6 +65,7 @@ internal class NewSubscriptionBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -138,6 +139,8 @@ internal class NewSubscriptionBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionBulkWithProrationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionBulkWithProrationPrice.metadata()) .contains( NewSubscriptionBulkWithProrationPrice.Metadata.builder() @@ -203,6 +206,7 @@ internal class NewSubscriptionBulkWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionBulkWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt index d04f7ee3d..00bbe9835 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionCumulativeGroupedBulkPriceTest.kt @@ -63,6 +63,7 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -134,6 +135,8 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionCumulativeGroupedBulkPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionCumulativeGroupedBulkPrice.metadata()) .contains( NewSubscriptionCumulativeGroupedBulkPrice.Metadata.builder() @@ -197,6 +200,7 @@ internal class NewSubscriptionCumulativeGroupedBulkPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionCumulativeGroupedBulkPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt index 2bad026b8..3a8de1294 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedAllocationPriceTest.kt @@ -54,6 +54,7 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -118,6 +119,8 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedAllocationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionGroupedAllocationPrice.metadata()) .contains( NewSubscriptionGroupedAllocationPrice.Metadata.builder() @@ -172,6 +175,7 @@ internal class NewSubscriptionGroupedAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt index 35e111782..a7b756233 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPackagePriceTest.kt @@ -69,6 +69,7 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -146,6 +147,8 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedTieredPackagePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionGroupedTieredPackagePrice.metadata()) .contains( NewSubscriptionGroupedTieredPackagePrice.Metadata.builder() @@ -215,6 +218,7 @@ internal class NewSubscriptionGroupedTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt index d74b508a1..7f649a4d4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedTieredPriceTest.kt @@ -64,6 +64,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -138,6 +139,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionGroupedTieredPrice.metadata()) .contains( NewSubscriptionGroupedTieredPrice.Metadata.builder() @@ -202,6 +204,7 @@ internal class NewSubscriptionGroupedTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt index 122ebb77b..f1aef9d49 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithMeteredMinimumPriceTest.kt @@ -77,6 +77,7 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -163,6 +164,8 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionGroupedWithMeteredMinimumPrice.metadata()) .contains( NewSubscriptionGroupedWithMeteredMinimumPrice.Metadata.builder() @@ -241,6 +244,7 @@ internal class NewSubscriptionGroupedWithMeteredMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithMeteredMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt index f82dd1066..64476d695 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionGroupedWithProratedMinimumPriceTest.kt @@ -58,6 +58,7 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -130,6 +131,8 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionGroupedWithProratedMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionGroupedWithProratedMinimumPrice.metadata()) .contains( NewSubscriptionGroupedWithProratedMinimumPrice.Metadata.builder() @@ -189,6 +192,7 @@ internal class NewSubscriptionGroupedWithProratedMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionGroupedWithProratedMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt index 2c6dac335..5297a855d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixPriceTest.kt @@ -59,6 +59,7 @@ internal class NewSubscriptionMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -126,6 +127,7 @@ internal class NewSubscriptionMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMatrixPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionMatrixPrice.metadata()) .contains( NewSubscriptionMatrixPrice.Metadata.builder() @@ -185,6 +187,7 @@ internal class NewSubscriptionMatrixPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt index 5ac3dfef8..1d8c78066 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithAllocationPriceTest.kt @@ -62,6 +62,7 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -132,6 +133,8 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMatrixWithAllocationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionMatrixWithAllocationPrice.metadata()) .contains( NewSubscriptionMatrixWithAllocationPrice.Metadata.builder() @@ -194,6 +197,7 @@ internal class NewSubscriptionMatrixWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt index 6ed09c6ac..b21dbdf5b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMatrixWithDisplayNamePriceTest.kt @@ -63,6 +63,7 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -134,6 +135,8 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMatrixWithDisplayNamePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionMatrixWithDisplayNamePrice.metadata()) .contains( NewSubscriptionMatrixWithDisplayNamePrice.Metadata.builder() @@ -197,6 +200,7 @@ internal class NewSubscriptionMatrixWithDisplayNamePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMatrixWithDisplayNamePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt index 4ebf6136c..c1ac1e30b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMaxGroupTieredPackagePriceTest.kt @@ -71,6 +71,7 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,8 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMaxGroupTieredPackagePrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionMaxGroupTieredPackagePrice.metadata()) .contains( NewSubscriptionMaxGroupTieredPackagePrice.Metadata.builder() @@ -219,6 +222,7 @@ internal class NewSubscriptionMaxGroupTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMaxGroupTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt index 19dedc47c..8bfeabc78 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionMinimumCompositePriceTest.kt @@ -53,6 +53,7 @@ internal class NewSubscriptionMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -116,6 +117,7 @@ internal class NewSubscriptionMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionMinimumCompositePrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionMinimumCompositePrice.metadata()) .contains( NewSubscriptionMinimumCompositePrice.Metadata.builder() @@ -169,6 +171,7 @@ internal class NewSubscriptionMinimumCompositePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionMinimumCompositePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt index 169262636..291135cba 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackagePriceTest.kt @@ -50,6 +50,7 @@ internal class NewSubscriptionPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -108,6 +109,7 @@ internal class NewSubscriptionPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionPackagePrice.metadata()) .contains( NewSubscriptionPackagePrice.Metadata.builder() @@ -158,6 +160,7 @@ internal class NewSubscriptionPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt index 0a6d6087b..3b813e67b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionPackageWithAllocationPriceTest.kt @@ -56,6 +56,7 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -120,6 +121,8 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionPackageWithAllocationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionPackageWithAllocationPrice.metadata()) .contains( NewSubscriptionPackageWithAllocationPrice.Metadata.builder() @@ -176,6 +179,7 @@ internal class NewSubscriptionPackageWithAllocationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionPackageWithAllocationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt index ddc357025..fedd9901e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithTieredPricingPriceTest.kt @@ -86,6 +86,7 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -196,6 +197,8 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionScalableMatrixWithTieredPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionScalableMatrixWithTieredPricingPrice.metadata()) .contains( NewSubscriptionScalableMatrixWithTieredPricingPrice.Metadata.builder() @@ -283,6 +286,7 @@ internal class NewSubscriptionScalableMatrixWithTieredPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithTieredPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt index 312ab4b27..b3f2eef1e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionScalableMatrixWithUnitPricingPriceTest.kt @@ -37,6 +37,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -70,6 +71,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -107,6 +109,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -159,6 +162,8 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionScalableMatrixWithUnitPricingPrice.metadata()) .contains( NewSubscriptionScalableMatrixWithUnitPricingPrice.Metadata.builder() @@ -197,6 +202,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .build() ) .unitPrice("unit_price") + .groupingKey("x") .prorate(true) .secondDimension("second_dimension") .build() @@ -230,6 +236,7 @@ internal class NewSubscriptionScalableMatrixWithUnitPricingPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionScalableMatrixWithUnitPricingPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt index d002d94c0..9198891c6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionThresholdTotalAmountPriceTest.kt @@ -70,6 +70,7 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -148,6 +149,8 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionThresholdTotalAmountPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionThresholdTotalAmountPrice.metadata()) .contains( NewSubscriptionThresholdTotalAmountPrice.Metadata.builder() @@ -218,6 +221,7 @@ internal class NewSubscriptionThresholdTotalAmountPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionThresholdTotalAmountPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt index 0357b6191..c523914c8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackagePriceTest.kt @@ -64,6 +64,7 @@ internal class NewSubscriptionTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -138,6 +139,7 @@ internal class NewSubscriptionTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredPackagePrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionTieredPackagePrice.metadata()) .contains( NewSubscriptionTieredPackagePrice.Metadata.builder() @@ -202,6 +204,7 @@ internal class NewSubscriptionTieredPackagePriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackagePrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt index 110d066f6..c9dc66e10 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPackageWithMinimumPriceTest.kt @@ -76,6 +76,7 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -159,6 +160,8 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredPackageWithMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionTieredPackageWithMinimumPrice.metadata()) .contains( NewSubscriptionTieredPackageWithMinimumPrice.Metadata.builder() @@ -236,6 +239,7 @@ internal class NewSubscriptionTieredPackageWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPackageWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt index 5260ed9e8..f387450e8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredPriceTest.kt @@ -59,6 +59,7 @@ internal class NewSubscriptionTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -126,6 +127,7 @@ internal class NewSubscriptionTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionTieredPrice.metadata()) .contains( NewSubscriptionTieredPrice.Metadata.builder() @@ -185,6 +187,7 @@ internal class NewSubscriptionTieredPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt index 822033076..cdfe808c6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionTieredWithMinimumPriceTest.kt @@ -69,6 +69,7 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -146,6 +147,8 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionTieredWithMinimumPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionTieredWithMinimumPrice.metadata()) .contains( NewSubscriptionTieredWithMinimumPrice.Metadata.builder() @@ -215,6 +218,7 @@ internal class NewSubscriptionTieredWithMinimumPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionTieredWithMinimumPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt index d9a6fe54d..39d8a9449 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitPriceTest.kt @@ -48,6 +48,7 @@ internal class NewSubscriptionUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -104,6 +105,7 @@ internal class NewSubscriptionUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionUnitPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionUnitPrice.metadata()) .contains( NewSubscriptionUnitPrice.Metadata.builder() @@ -152,6 +154,7 @@ internal class NewSubscriptionUnitPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt index dee30f504..20dc58ccf 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithPercentPriceTest.kt @@ -53,6 +53,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -116,6 +117,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionUnitWithPercentPrice.licenseTypeId()).contains("license_type_id") assertThat(newSubscriptionUnitWithPercentPrice.metadata()) .contains( NewSubscriptionUnitWithPercentPrice.Metadata.builder() @@ -169,6 +171,7 @@ internal class NewSubscriptionUnitWithPercentPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithPercentPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt index 9dd1ce78d..1d19980ea 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewSubscriptionUnitWithProrationPriceTest.kt @@ -52,6 +52,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,6 +115,8 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + assertThat(newSubscriptionUnitWithProrationPrice.licenseTypeId()) + .contains("license_type_id") assertThat(newSubscriptionUnitWithProrationPrice.metadata()) .contains( NewSubscriptionUnitWithProrationPrice.Metadata.builder() @@ -166,6 +169,7 @@ internal class NewSubscriptionUnitWithProrationPriceTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitWithProrationPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt index 210a3f813..8c782e692 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PerPriceCostTest.kt @@ -56,6 +56,7 @@ internal class PerPriceCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -77,6 +78,7 @@ internal class PerPriceCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -130,6 +132,13 @@ internal class PerPriceCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -181,6 +190,7 @@ internal class PerPriceCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -202,6 +212,7 @@ internal class PerPriceCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -255,6 +266,13 @@ internal class PerPriceCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -310,6 +328,7 @@ internal class PerPriceCostTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -331,6 +350,7 @@ internal class PerPriceCostTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -384,6 +404,13 @@ internal class PerPriceCostTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") 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 c4bbae5ee..c82a498af 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 @@ -36,9 +36,75 @@ internal class PlanCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.builder() + .cadence(PlanCreateParams.Price.LicenseAllocationPrice.Cadence.ANNUAL) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType(PlanCreateParams.Price.LicenseAllocationPrice.ModelType.UNIT) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -83,6 +149,7 @@ internal class PlanCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -122,6 +189,7 @@ internal class PlanCreateParamsTest { .build() ) .defaultInvoiceMemo("default_invoice_memo") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanCreateParams.Metadata.builder() @@ -169,9 +237,81 @@ internal class PlanCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Cadence.ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + PlanCreateParams.Price.LicenseAllocationPrice.ModelType.UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -218,6 +358,7 @@ internal class PlanCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -257,6 +398,7 @@ internal class PlanCreateParamsTest { .build() ) .defaultInvoiceMemo("default_invoice_memo") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanCreateParams.Metadata.builder() @@ -302,9 +444,75 @@ internal class PlanCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.builder() + .cadence(PlanCreateParams.Price.LicenseAllocationPrice.Cadence.ANNUAL) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice.LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType(PlanCreateParams.Price.LicenseAllocationPrice.ModelType.UNIT) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -349,6 +557,7 @@ internal class PlanCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -389,6 +598,7 @@ internal class PlanCreateParamsTest { .build() ) assertThat(body.defaultInvoiceMemo()).contains("default_invoice_memo") + assertThat(body.description()).contains("description") assertThat(body.externalPlanId()).contains("external_plan_id") assertThat(body.metadata()) .contains( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParamsTest.kt index 9318a3651..7192e19c7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParamsTest.kt @@ -12,6 +12,7 @@ internal class PlanExternalPlanIdUpdateParamsTest { fun create() { PlanExternalPlanIdUpdateParams.builder() .otherExternalPlanId("external_plan_id") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanExternalPlanIdUpdateParams.Metadata.builder() @@ -36,6 +37,7 @@ internal class PlanExternalPlanIdUpdateParamsTest { val params = PlanExternalPlanIdUpdateParams.builder() .otherExternalPlanId("external_plan_id") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanExternalPlanIdUpdateParams.Metadata.builder() @@ -46,6 +48,7 @@ internal class PlanExternalPlanIdUpdateParamsTest { val body = params._body() + assertThat(body.description()).contains("description") assertThat(body.externalPlanId()).contains("external_plan_id") assertThat(body.metadata()) .contains( 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 f88092a24..ca5207689 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 @@ -210,6 +210,7 @@ internal class PlanListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -233,6 +234,7 @@ internal class PlanListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -289,6 +291,13 @@ internal class PlanListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -502,6 +511,7 @@ internal class PlanListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -523,6 +533,7 @@ internal class PlanListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -579,6 +590,13 @@ internal class PlanListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -802,6 +820,7 @@ internal class PlanListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -825,6 +844,7 @@ internal class PlanListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -881,6 +901,13 @@ internal class PlanListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationCancelResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationCancelResponseTest.kt index 9e0871bbf..d3ae8c517 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationCancelResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationCancelResponseTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.jsonMapper -import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,7 +14,7 @@ internal class PlanMigrationCancelResponseTest { val planMigrationCancelResponse = PlanMigrationCancelResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationCancelResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationCancelResponse.Status.NOT_STARTED) .build() @@ -23,7 +22,9 @@ internal class PlanMigrationCancelResponseTest { assertThat(planMigrationCancelResponse.id()).isEqualTo("id") assertThat(planMigrationCancelResponse.effectiveTime()) .contains( - PlanMigrationCancelResponse.EffectiveTime.ofLocalDate(LocalDate.parse("2019-12-27")) + PlanMigrationCancelResponse.EffectiveTime.ofUnionMember2( + PlanMigrationCancelResponse.EffectiveTime.UnionMember2.END_OF_TERM + ) ) assertThat(planMigrationCancelResponse.planId()).isEqualTo("plan_id") assertThat(planMigrationCancelResponse.status()) @@ -36,7 +37,7 @@ internal class PlanMigrationCancelResponseTest { val planMigrationCancelResponse = PlanMigrationCancelResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationCancelResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationCancelResponse.Status.NOT_STARTED) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListPageResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListPageResponseTest.kt index 27e2f6f52..e69638f15 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListPageResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListPageResponseTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.jsonMapper -import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -17,7 +16,9 @@ internal class PlanMigrationListPageResponseTest { .addData( PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime( + PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM + ) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() @@ -31,7 +32,7 @@ internal class PlanMigrationListPageResponseTest { .containsExactly( PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() @@ -48,7 +49,9 @@ internal class PlanMigrationListPageResponseTest { .addData( PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime( + PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM + ) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListResponseTest.kt index 6191009db..acb45bc14 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationListResponseTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.jsonMapper -import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,7 +14,7 @@ internal class PlanMigrationListResponseTest { val planMigrationListResponse = PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() @@ -23,7 +22,9 @@ internal class PlanMigrationListResponseTest { assertThat(planMigrationListResponse.id()).isEqualTo("id") assertThat(planMigrationListResponse.effectiveTime()) .contains( - PlanMigrationListResponse.EffectiveTime.ofLocalDate(LocalDate.parse("2019-12-27")) + PlanMigrationListResponse.EffectiveTime.ofUnionMember2( + PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM + ) ) assertThat(planMigrationListResponse.planId()).isEqualTo("plan_id") assertThat(planMigrationListResponse.status()) @@ -36,7 +37,7 @@ internal class PlanMigrationListResponseTest { val planMigrationListResponse = PlanMigrationListResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationListResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationListResponse.Status.NOT_STARTED) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponseTest.kt index f987f63ab..3eac3fe67 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMigrationRetrieveResponseTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.withorb.api.core.jsonMapper -import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,7 +14,7 @@ internal class PlanMigrationRetrieveResponseTest { val planMigrationRetrieveResponse = PlanMigrationRetrieveResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationRetrieveResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationRetrieveResponse.Status.NOT_STARTED) .build() @@ -23,8 +22,8 @@ internal class PlanMigrationRetrieveResponseTest { assertThat(planMigrationRetrieveResponse.id()).isEqualTo("id") assertThat(planMigrationRetrieveResponse.effectiveTime()) .contains( - PlanMigrationRetrieveResponse.EffectiveTime.ofLocalDate( - LocalDate.parse("2019-12-27") + PlanMigrationRetrieveResponse.EffectiveTime.ofUnionMember2( + PlanMigrationRetrieveResponse.EffectiveTime.UnionMember2.END_OF_TERM ) ) assertThat(planMigrationRetrieveResponse.planId()).isEqualTo("plan_id") @@ -38,7 +37,7 @@ internal class PlanMigrationRetrieveResponseTest { val planMigrationRetrieveResponse = PlanMigrationRetrieveResponse.builder() .id("id") - .effectiveTime(LocalDate.parse("2019-12-27")) + .effectiveTime(PlanMigrationRetrieveResponse.EffectiveTime.UnionMember2.END_OF_TERM) .planId("plan_id") .status(PlanMigrationRetrieveResponse.Status.NOT_STARTED) .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 851d4c480..2f6b99c02 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 @@ -198,6 +198,7 @@ internal class PlanTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -219,6 +220,7 @@ internal class PlanTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -272,6 +274,13 @@ internal class PlanTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -486,6 +495,7 @@ internal class PlanTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -507,6 +517,7 @@ internal class PlanTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -560,6 +571,13 @@ internal class PlanTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -769,6 +787,7 @@ internal class PlanTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -790,6 +809,7 @@ internal class PlanTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -843,6 +863,13 @@ internal class PlanTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanUpdateParamsTest.kt index 25282ce24..44092b285 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanUpdateParamsTest.kt @@ -12,6 +12,7 @@ internal class PlanUpdateParamsTest { fun create() { PlanUpdateParams.builder() .planId("plan_id") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanUpdateParams.Metadata.builder() @@ -35,6 +36,7 @@ internal class PlanUpdateParamsTest { val params = PlanUpdateParams.builder() .planId("plan_id") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanUpdateParams.Metadata.builder() @@ -45,6 +47,7 @@ internal class PlanUpdateParamsTest { val body = params._body() + assertThat(body.description()).contains("description") assertThat(body.externalPlanId()).contains("external_plan_id") assertThat(body.metadata()) .contains( diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt index be7ed5eff..7cfb2a5f0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanVersionTest.kt @@ -89,6 +89,7 @@ internal class PlanVersionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -110,6 +111,7 @@ internal class PlanVersionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -163,6 +165,13 @@ internal class PlanVersionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .version(0L) @@ -248,6 +257,7 @@ internal class PlanVersionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -269,6 +279,7 @@ internal class PlanVersionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -322,6 +333,13 @@ internal class PlanVersionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -406,6 +424,7 @@ internal class PlanVersionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -427,6 +446,7 @@ internal class PlanVersionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -480,6 +500,13 @@ internal class PlanVersionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .version(0L) 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 4f4e9b97c..21470db42 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 @@ -49,6 +49,7 @@ internal class PriceCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -103,6 +104,7 @@ internal class PriceCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -156,6 +158,7 @@ internal class PriceCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt index eb10246d1..148355434 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateMultipleParamsTest.kt @@ -22,6 +22,12 @@ internal class PriceEvaluateMultipleParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -65,6 +71,7 @@ internal class PriceEvaluateMultipleParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -91,6 +98,12 @@ internal class PriceEvaluateMultipleParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -136,6 +149,7 @@ internal class PriceEvaluateMultipleParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -161,6 +175,12 @@ internal class PriceEvaluateMultipleParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -204,6 +224,7 @@ internal class PriceEvaluateMultipleParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt index c017f5856..e41ef0c44 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluateParamsTest.kt @@ -2,6 +2,7 @@ package com.withorb.api.models +import com.withorb.api.core.JsonValue import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -19,6 +20,11 @@ internal class PriceEvaluateParamsTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() } @@ -47,6 +53,11 @@ internal class PriceEvaluateParamsTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val body = params._body() @@ -60,6 +71,12 @@ internal class PriceEvaluateParamsTest { .contains("my_numeric_property > 100 AND my_other_property = 'bar'") assertThat(body.groupingKeys().getOrNull()) .containsExactly("case when my_event_type = 'foo' then true else false end") + assertThat(body.metricParameterOverrides()) + .contains( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt index 40a74d21f..9133061a5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceEvaluatePreviewEventsParamsTest.kt @@ -35,6 +35,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -78,6 +84,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -117,6 +124,13 @@ internal class PriceEvaluatePreviewEventsParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -162,6 +176,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -201,6 +216,12 @@ internal class PriceEvaluatePreviewEventsParamsTest { .externalPriceId("external_price_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -244,6 +265,7 @@ internal class PriceEvaluatePreviewEventsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt index 91f34c657..64dc35112 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalTest.kt @@ -71,6 +71,7 @@ internal class PriceIntervalTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -92,6 +93,7 @@ internal class PriceIntervalTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -145,10 +147,22 @@ internal class PriceIntervalTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() assertThat(priceInterval.id()).isEqualTo("id") @@ -212,6 +226,7 @@ internal class PriceIntervalTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -233,6 +248,7 @@ internal class PriceIntervalTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -286,12 +302,25 @@ internal class PriceIntervalTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) assertThat(priceInterval.startDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(priceInterval.usageCustomerIds().getOrNull()).containsExactly("string") + assertThat(priceInterval.metricParameterOverrides()) + .contains( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test @@ -354,6 +383,7 @@ internal class PriceIntervalTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -375,6 +405,7 @@ internal class PriceIntervalTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -428,10 +459,22 @@ internal class PriceIntervalTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val roundtrippedPriceInterval = 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 adcd2fae7..88bc2fd79 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 @@ -56,6 +56,7 @@ internal class PriceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -77,6 +78,7 @@ internal class PriceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -130,6 +132,13 @@ internal class PriceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .paginationMetadata( @@ -180,6 +189,7 @@ internal class PriceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -201,6 +211,7 @@ internal class PriceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -254,6 +265,13 @@ internal class PriceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) ) @@ -307,6 +325,7 @@ internal class PriceListPageResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -328,6 +347,7 @@ internal class PriceListPageResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -381,6 +401,13 @@ internal class PriceListPageResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .paginationMetadata( 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 158dacf8c..5fa76c9b0 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 @@ -58,6 +58,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -79,6 +80,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -130,6 +132,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofUnit(unit) @@ -148,6 +157,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -162,6 +172,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -212,6 +224,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -233,6 +246,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -286,6 +300,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -338,6 +359,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -359,6 +381,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -421,6 +444,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Tiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTiered(tiered) @@ -439,6 +469,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -453,6 +484,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -503,6 +536,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -524,6 +558,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -586,6 +621,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Tiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -645,6 +687,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -666,6 +709,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -716,6 +760,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Bulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofBulk(bulk) @@ -734,6 +785,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -748,6 +800,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -808,6 +862,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -829,6 +884,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -879,6 +935,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Bulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -953,6 +1016,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -974,6 +1038,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1024,6 +1089,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithFilters.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofBulkWithFilters(bulkWithFilters) @@ -1042,6 +1114,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -1056,6 +1129,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -1128,6 +1203,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1149,6 +1225,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1199,6 +1276,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithFilters.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -1251,6 +1335,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1272,6 +1357,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1325,6 +1411,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Package.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofPackage(package_) @@ -1343,6 +1436,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -1357,6 +1451,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -1407,6 +1503,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1428,6 +1525,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1484,6 +1582,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Package.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -1536,6 +1641,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1557,6 +1663,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1619,6 +1726,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Matrix.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMatrix(matrix) @@ -1637,6 +1751,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -1651,6 +1766,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -1701,6 +1818,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1722,6 +1840,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1784,6 +1903,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Matrix.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -1836,6 +1962,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1857,6 +1984,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1926,6 +2054,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ThresholdTotalAmount.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) @@ -1944,6 +2079,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -1958,6 +2094,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -2010,6 +2148,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2031,6 +2170,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2102,6 +2242,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.ThresholdTotalAmount.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -2154,6 +2301,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2175,6 +2323,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2242,6 +2391,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredPackage(tieredPackage) @@ -2260,6 +2416,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -2274,6 +2431,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -2324,6 +2483,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2345,6 +2505,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2412,6 +2573,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -2464,6 +2632,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2485,6 +2654,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2555,6 +2725,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredWithMinimum(tieredWithMinimum) @@ -2573,6 +2750,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -2587,6 +2765,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -2639,6 +2819,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2660,6 +2841,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2730,6 +2912,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -2782,6 +2971,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2820,6 +3010,7 @@ internal class PriceTest { ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2870,6 +3061,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofGroupedTiered(groupedTiered) @@ -2888,6 +3086,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -2902,6 +3101,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -2952,6 +3153,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2990,6 +3192,7 @@ internal class PriceTest { ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3040,6 +3243,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTiered.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3094,6 +3304,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3115,6 +3326,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3186,6 +3398,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackageWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) @@ -3204,6 +3423,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -3218,6 +3438,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -3273,6 +3495,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3294,6 +3517,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3365,6 +3589,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredPackageWithMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3419,6 +3650,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3440,6 +3672,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3497,6 +3730,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.PackageWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofPackageWithAllocation(packageWithAllocation) @@ -3515,6 +3755,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).contains(packageWithAllocation) assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -3529,6 +3770,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -3581,6 +3824,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3602,6 +3846,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3659,6 +3904,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.PackageWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3711,6 +3963,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3732,6 +3985,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3788,6 +4042,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithPercent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofUnitWithPercent(unitWithPercent) @@ -3806,6 +4067,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).contains(unitWithPercent) assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -3820,6 +4082,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -3870,6 +4134,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3891,6 +4156,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3947,6 +4213,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithPercent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -3999,6 +4272,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4020,6 +4294,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4083,6 +4358,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMatrixWithAllocation(matrixWithAllocation) @@ -4101,6 +4383,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).contains(matrixWithAllocation) + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -4115,6 +4398,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -4167,6 +4452,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4188,6 +4474,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4251,6 +4538,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -4261,9 +4555,9 @@ internal class PriceTest { } @Test - fun ofTieredWithProration() { - val tieredWithProration = - Price.TieredWithProration.builder() + fun ofMatrixWithThresholdDiscounts() { + val matrixWithThresholdDiscounts = + Price.MatrixWithThresholdDiscounts.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4272,12 +4566,17 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) - .cadence(Price.TieredWithProration.Cadence.ONE_TIME) + .billingMode(Price.MatrixWithThresholdDiscounts.BillingMode.IN_ADVANCE) + .cadence(Price.MatrixWithThresholdDiscounts.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.TieredWithProration.CompositePriceFilter.builder() - .field(Price.TieredWithProration.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.TieredWithProration.CompositePriceFilter.Operator.INCLUDES) + Price.MatrixWithThresholdDiscounts.CompositePriceFilter.builder() + .field( + Price.MatrixWithThresholdDiscounts.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.MatrixWithThresholdDiscounts.CompositePriceFilter.Operator + .INCLUDES + ) .addValue("string") .build() ) @@ -4303,6 +4602,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4324,6 +4624,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4331,6 +4632,37 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixWithThresholdDiscountsConfig( + Price.MatrixWithThresholdDiscounts.MatrixWithThresholdDiscountsConfig.builder() + .defaultUnitAmount("default_unit_amount") + .firstDimension("first_dimension") + .addMatrixValue( + Price.MatrixWithThresholdDiscounts.MatrixWithThresholdDiscountsConfig + .MatrixValue + .builder() + .firstDimensionValue("first_dimension_value") + .unitAmount("unit_amount") + .secondDimensionValue("second_dimension_value") + .build() + ) + .secondDimension("second_dimension") + .addThresholdDiscountGroup( + Price.MatrixWithThresholdDiscounts.MatrixWithThresholdDiscountsConfig + .ThresholdDiscountGroup + .builder() + .aboveThresholdDiscountPercentage( + "above_threshold_discount_percentage" + ) + .belowThresholdDiscountPercentage( + "below_threshold_discount_percentage" + ) + .cellCoordinates("cell_coordinates") + .thresholdAmount("threshold_amount") + .description("description") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -4346,7 +4678,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithProration.Metadata.builder() + Price.MatrixWithThresholdDiscounts.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4366,27 +4698,24 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithThresholdDiscounts.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredWithProrationConfig( - Price.TieredWithProration.TieredWithProrationConfig.builder() - .addTier( - Price.TieredWithProration.TieredWithProrationConfig.Tier.builder() - .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") - .build() - ) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithThresholdDiscounts.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofTieredWithProration(tieredWithProration) + val price = Price.ofMatrixWithThresholdDiscounts(matrixWithThresholdDiscounts) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -4402,7 +4731,8 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty - assertThat(price.tieredWithProration()).contains(tieredWithProration) + assertThat(price.matrixWithThresholdDiscounts()).contains(matrixWithThresholdDiscounts) + assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty assertThat(price.bulkWithProration()).isEmpty @@ -4416,17 +4746,19 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofTieredWithProrationRoundtrip() { + fun ofMatrixWithThresholdDiscountsRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofTieredWithProration( - Price.TieredWithProration.builder() + Price.ofMatrixWithThresholdDiscounts( + Price.MatrixWithThresholdDiscounts.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4435,13 +4767,17 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) - .cadence(Price.TieredWithProration.Cadence.ONE_TIME) + .billingMode(Price.MatrixWithThresholdDiscounts.BillingMode.IN_ADVANCE) + .cadence(Price.MatrixWithThresholdDiscounts.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.TieredWithProration.CompositePriceFilter.builder() - .field(Price.TieredWithProration.CompositePriceFilter.Field.PRICE_ID) + Price.MatrixWithThresholdDiscounts.CompositePriceFilter.builder() + .field( + Price.MatrixWithThresholdDiscounts.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - Price.TieredWithProration.CompositePriceFilter.Operator.INCLUDES + Price.MatrixWithThresholdDiscounts.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -4468,6 +4804,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4489,6 +4826,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4496,6 +4834,40 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixWithThresholdDiscountsConfig( + Price.MatrixWithThresholdDiscounts.MatrixWithThresholdDiscountsConfig + .builder() + .defaultUnitAmount("default_unit_amount") + .firstDimension("first_dimension") + .addMatrixValue( + Price.MatrixWithThresholdDiscounts + .MatrixWithThresholdDiscountsConfig + .MatrixValue + .builder() + .firstDimensionValue("first_dimension_value") + .unitAmount("unit_amount") + .secondDimensionValue("second_dimension_value") + .build() + ) + .secondDimension("second_dimension") + .addThresholdDiscountGroup( + Price.MatrixWithThresholdDiscounts + .MatrixWithThresholdDiscountsConfig + .ThresholdDiscountGroup + .builder() + .aboveThresholdDiscountPercentage( + "above_threshold_discount_percentage" + ) + .belowThresholdDiscountPercentage( + "below_threshold_discount_percentage" + ) + .cellCoordinates("cell_coordinates") + .thresholdAmount("threshold_amount") + .description("description") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -4511,7 +4883,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithProration.Metadata.builder() + Price.MatrixWithThresholdDiscounts.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4531,24 +4903,21 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithThresholdDiscounts.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .tieredWithProrationConfig( - Price.TieredWithProration.TieredWithProrationConfig.builder() - .addTier( - Price.TieredWithProration.TieredWithProrationConfig.Tier.builder() - .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") - .build() - ) - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithThresholdDiscounts.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -4559,9 +4928,9 @@ internal class PriceTest { } @Test - fun ofUnitWithProration() { - val unitWithProration = - Price.UnitWithProration.builder() + fun ofTieredWithProration() { + val tieredWithProration = + Price.TieredWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4570,12 +4939,12 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) - .cadence(Price.UnitWithProration.Cadence.ONE_TIME) + .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) + .cadence(Price.TieredWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.UnitWithProration.CompositePriceFilter.builder() - .field(Price.UnitWithProration.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.UnitWithProration.CompositePriceFilter.Operator.INCLUDES) + Price.TieredWithProration.CompositePriceFilter.builder() + .field(Price.TieredWithProration.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.TieredWithProration.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4601,6 +4970,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4622,6 +4992,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4644,7 +5015,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithProration.Metadata.builder() + Price.TieredWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4664,11 +5035,16 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitWithProrationConfig( - Price.UnitWithProration.UnitWithProrationConfig.builder() - .unitAmount("unit_amount") + .tieredWithProrationConfig( + Price.TieredWithProration.TieredWithProrationConfig.builder() + .addTier( + Price.TieredWithProration.TieredWithProrationConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .dimensionalPriceConfiguration( @@ -4677,9 +5053,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofUnitWithProration(unitWithProration) + val price = Price.ofTieredWithProration(tieredWithProration) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -4695,8 +5078,9 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty - assertThat(price.tieredWithProration()).isEmpty - assertThat(price.unitWithProration()).contains(unitWithProration) + assertThat(price.matrixWithThresholdDiscounts()).isEmpty + assertThat(price.tieredWithProration()).contains(tieredWithProration) + assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty @@ -4709,17 +5093,19 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofUnitWithProrationRoundtrip() { + fun ofTieredWithProrationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofUnitWithProration( - Price.UnitWithProration.builder() + Price.ofTieredWithProration( + Price.TieredWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4728,13 +5114,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) - .cadence(Price.UnitWithProration.Cadence.ONE_TIME) + .billingMode(Price.TieredWithProration.BillingMode.IN_ADVANCE) + .cadence(Price.TieredWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.UnitWithProration.CompositePriceFilter.builder() - .field(Price.UnitWithProration.CompositePriceFilter.Field.PRICE_ID) + Price.TieredWithProration.CompositePriceFilter.builder() + .field(Price.TieredWithProration.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.UnitWithProration.CompositePriceFilter.Operator.INCLUDES + Price.TieredWithProration.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -4761,6 +5147,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4782,6 +5169,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4804,7 +5192,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithProration.Metadata.builder() + Price.TieredWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4824,11 +5212,16 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .unitWithProrationConfig( - Price.UnitWithProration.UnitWithProrationConfig.builder() - .unitAmount("unit_amount") + .tieredWithProrationConfig( + Price.TieredWithProration.TieredWithProrationConfig.builder() + .addTier( + Price.TieredWithProration.TieredWithProrationConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) .build() ) .dimensionalPriceConfiguration( @@ -4837,6 +5230,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.TieredWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -4847,9 +5247,9 @@ internal class PriceTest { } @Test - fun ofGroupedAllocation() { - val groupedAllocation = - Price.GroupedAllocation.builder() + fun ofUnitWithProration() { + val unitWithProration = + Price.UnitWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -4858,12 +5258,12 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) - .addCompositePriceFilter( - Price.GroupedAllocation.CompositePriceFilter.builder() - .field(Price.GroupedAllocation.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.GroupedAllocation.CompositePriceFilter.Operator.INCLUDES) + .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) + .cadence(Price.UnitWithProration.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.UnitWithProration.CompositePriceFilter.builder() + .field(Price.UnitWithProration.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.UnitWithProration.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -4889,6 +5289,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4910,13 +5311,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedAllocationConfig( - Price.GroupedAllocation.GroupedAllocationConfig.builder() - .allocation("allocation") - .groupingKey("x") - .overageUnitRate("overage_unit_rate") - .build() - ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4939,7 +5334,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedAllocation.Metadata.builder() + Price.UnitWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -4959,17 +5354,29 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .unitWithProrationConfig( + Price.UnitWithProration.UnitWithProrationConfig.builder() + .unitAmount("unit_amount") + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofGroupedAllocation(groupedAllocation) + val price = Price.ofUnitWithProration(unitWithProration) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -4985,9 +5392,10 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty - assertThat(price.unitWithProration()).isEmpty - assertThat(price.groupedAllocation()).contains(groupedAllocation) + assertThat(price.unitWithProration()).contains(unitWithProration) + assertThat(price.groupedAllocation()).isEmpty assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty @@ -4999,17 +5407,19 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedAllocationRoundtrip() { + fun ofUnitWithProrationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedAllocation( - Price.GroupedAllocation.builder() + Price.ofUnitWithProration( + Price.UnitWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5018,13 +5428,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) + .billingMode(Price.UnitWithProration.BillingMode.IN_ADVANCE) + .cadence(Price.UnitWithProration.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.GroupedAllocation.CompositePriceFilter.builder() - .field(Price.GroupedAllocation.CompositePriceFilter.Field.PRICE_ID) + Price.UnitWithProration.CompositePriceFilter.builder() + .field(Price.UnitWithProration.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.GroupedAllocation.CompositePriceFilter.Operator.INCLUDES + Price.UnitWithProration.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -5051,6 +5461,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5072,13 +5483,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedAllocationConfig( - Price.GroupedAllocation.GroupedAllocationConfig.builder() - .allocation("allocation") - .groupingKey("x") - .overageUnitRate("overage_unit_rate") - .build() - ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5101,7 +5506,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedAllocation.Metadata.builder() + Price.UnitWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5121,14 +5526,26 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") + .unitWithProrationConfig( + Price.UnitWithProration.UnitWithProrationConfig.builder() + .unitAmount("unit_amount") + .build() + ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -5139,9 +5556,9 @@ internal class PriceTest { } @Test - fun ofBulkWithProration() { - val bulkWithProration = - Price.BulkWithProration.builder() + fun ofGroupedAllocation() { + val groupedAllocation = + Price.GroupedAllocation.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5150,28 +5567,12 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.BulkWithProration.BillingMode.IN_ADVANCE) - .bulkWithProrationConfig( - Price.BulkWithProration.BulkWithProrationConfig.builder() - .addTier( - Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() - .unitAmount("unit_amount") - .tierLowerBound("tier_lower_bound") - .build() - ) - .addTier( - Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() - .unitAmount("unit_amount") - .tierLowerBound("tier_lower_bound") - .build() - ) - .build() - ) - .cadence(Price.BulkWithProration.Cadence.ONE_TIME) + .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.BulkWithProration.CompositePriceFilter.builder() - .field(Price.BulkWithProration.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.BulkWithProration.CompositePriceFilter.Operator.INCLUDES) + Price.GroupedAllocation.CompositePriceFilter.builder() + .field(Price.GroupedAllocation.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.GroupedAllocation.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5197,6 +5598,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5218,6 +5620,14 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedAllocationConfig( + Price.GroupedAllocation.GroupedAllocationConfig.builder() + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") + .build() + ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5240,7 +5650,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkWithProration.Metadata.builder() + Price.GroupedAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5260,7 +5670,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) + .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5268,9 +5678,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofBulkWithProration(bulkWithProration) + val price = Price.ofGroupedAllocation(groupedAllocation) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -5286,10 +5703,11 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty - assertThat(price.groupedAllocation()).isEmpty - assertThat(price.bulkWithProration()).contains(bulkWithProration) + assertThat(price.groupedAllocation()).contains(groupedAllocation) + assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty assertThat(price.groupedWithMinMaxThresholds()).isEmpty @@ -5300,17 +5718,19 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofBulkWithProrationRoundtrip() { + fun ofGroupedAllocationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofBulkWithProration( - Price.BulkWithProration.builder() + Price.ofGroupedAllocation( + Price.GroupedAllocation.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5319,29 +5739,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.BulkWithProration.BillingMode.IN_ADVANCE) - .bulkWithProrationConfig( - Price.BulkWithProration.BulkWithProrationConfig.builder() - .addTier( - Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() - .unitAmount("unit_amount") - .tierLowerBound("tier_lower_bound") - .build() - ) - .addTier( - Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() - .unitAmount("unit_amount") - .tierLowerBound("tier_lower_bound") - .build() - ) - .build() - ) - .cadence(Price.BulkWithProration.Cadence.ONE_TIME) + .billingMode(Price.GroupedAllocation.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.BulkWithProration.CompositePriceFilter.builder() - .field(Price.BulkWithProration.CompositePriceFilter.Field.PRICE_ID) + Price.GroupedAllocation.CompositePriceFilter.builder() + .field(Price.GroupedAllocation.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.BulkWithProration.CompositePriceFilter.Operator.INCLUDES + Price.GroupedAllocation.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -5368,6 +5772,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5389,6 +5794,14 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedAllocationConfig( + Price.GroupedAllocation.GroupedAllocationConfig.builder() + .allocation("allocation") + .groupingKey("x") + .overageUnitRate("overage_unit_rate") + .build() + ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5411,7 +5824,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.BulkWithProration.Metadata.builder() + Price.GroupedAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5431,7 +5844,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) + .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5439,6 +5852,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -5449,9 +5869,9 @@ internal class PriceTest { } @Test - fun ofGroupedWithProratedMinimum() { - val groupedWithProratedMinimum = - Price.GroupedWithProratedMinimum.builder() + fun ofBulkWithProration() { + val bulkWithProration = + Price.BulkWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5460,14 +5880,28 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) - .addCompositePriceFilter( - Price.GroupedWithProratedMinimum.CompositePriceFilter.builder() - .field(Price.GroupedWithProratedMinimum.CompositePriceFilter.Field.PRICE_ID) - .operator( - Price.GroupedWithProratedMinimum.CompositePriceFilter.Operator.INCLUDES + .billingMode(Price.BulkWithProration.BillingMode.IN_ADVANCE) + .bulkWithProrationConfig( + Price.BulkWithProration.BulkWithProrationConfig.builder() + .addTier( + Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() ) + .build() + ) + .cadence(Price.BulkWithProration.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.BulkWithProration.CompositePriceFilter.builder() + .field(Price.BulkWithProration.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.BulkWithProration.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -5493,6 +5927,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5514,13 +5949,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithProratedMinimumConfig( - Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() - .groupingKey("x") - .minimum("minimum") - .unitRate("unit_rate") - .build() - ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5543,7 +5972,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithProratedMinimum.Metadata.builder() + Price.BulkWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5563,7 +5992,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) + .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5571,9 +6000,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) + val price = Price.ofBulkWithProration(bulkWithProration) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -5589,11 +6025,12 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty - assertThat(price.bulkWithProration()).isEmpty - assertThat(price.groupedWithProratedMinimum()).contains(groupedWithProratedMinimum) + assertThat(price.bulkWithProration()).contains(bulkWithProration) + assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty @@ -5603,17 +6040,19 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedWithProratedMinimumRoundtrip() { + fun ofBulkWithProrationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedWithProratedMinimum( - Price.GroupedWithProratedMinimum.builder() + Price.ofBulkWithProration( + Price.BulkWithProration.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5622,16 +6061,29 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) - .addCompositePriceFilter( - Price.GroupedWithProratedMinimum.CompositePriceFilter.builder() - .field( - Price.GroupedWithProratedMinimum.CompositePriceFilter.Field.PRICE_ID + .billingMode(Price.BulkWithProration.BillingMode.IN_ADVANCE) + .bulkWithProrationConfig( + Price.BulkWithProration.BulkWithProrationConfig.builder() + .addTier( + Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() + ) + .addTier( + Price.BulkWithProration.BulkWithProrationConfig.Tier.builder() + .unitAmount("unit_amount") + .tierLowerBound("tier_lower_bound") + .build() ) + .build() + ) + .cadence(Price.BulkWithProration.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.BulkWithProration.CompositePriceFilter.builder() + .field(Price.BulkWithProration.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.GroupedWithProratedMinimum.CompositePriceFilter.Operator - .INCLUDES + Price.BulkWithProration.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -5658,6 +6110,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5679,13 +6132,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithProratedMinimumConfig( - Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() - .groupingKey("x") - .minimum("minimum") - .unitRate("unit_rate") - .build() - ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5708,7 +6155,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithProratedMinimum.Metadata.builder() + Price.BulkWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5728,7 +6175,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) + .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5736,6 +6183,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.BulkWithProration.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -5746,9 +6200,9 @@ internal class PriceTest { } @Test - fun ofGroupedWithMeteredMinimum() { - val groupedWithMeteredMinimum = - Price.GroupedWithMeteredMinimum.builder() + fun ofGroupedWithProratedMinimum() { + val groupedWithProratedMinimum = + Price.GroupedWithProratedMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5757,13 +6211,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.GroupedWithMeteredMinimum.CompositePriceFilter.builder() - .field(Price.GroupedWithMeteredMinimum.CompositePriceFilter.Field.PRICE_ID) + Price.GroupedWithProratedMinimum.CompositePriceFilter.builder() + .field(Price.GroupedWithProratedMinimum.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.GroupedWithMeteredMinimum.CompositePriceFilter.Operator.INCLUDES + Price.GroupedWithProratedMinimum.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -5790,6 +6244,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5811,30 +6266,14 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMeteredMinimumConfig( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() + .groupedWithProratedMinimumConfig( + Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() .groupingKey("x") - .minimumUnitAmount("minimum_unit_amount") - .pricingKey("pricing_key") - .addScalingFactor( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig - .ScalingFactor - .builder() - .scalingFactor("scaling_factor") - .scalingValue("scaling_value") - .build() - ) - .scalingKey("scaling_key") - .addUnitAmount( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig - .UnitAmount - .builder() - .pricingValue("pricing_value") - .unitAmount("unit_amount") - .build() - ) + .minimum("minimum") + .unitRate("unit_rate") .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5857,7 +6296,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMeteredMinimum.Metadata.builder() + Price.GroupedWithProratedMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -5877,7 +6316,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -5885,9 +6324,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithProratedMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -5903,12 +6349,13 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty assertThat(price.bulkWithProration()).isEmpty - assertThat(price.groupedWithProratedMinimum()).isEmpty - assertThat(price.groupedWithMeteredMinimum()).contains(groupedWithMeteredMinimum) + assertThat(price.groupedWithProratedMinimum()).contains(groupedWithProratedMinimum) + assertThat(price.groupedWithMeteredMinimum()).isEmpty assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty @@ -5917,17 +6364,19 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedWithMeteredMinimumRoundtrip() { + fun ofGroupedWithProratedMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedWithMeteredMinimum( - Price.GroupedWithMeteredMinimum.builder() + Price.ofGroupedWithProratedMinimum( + Price.GroupedWithProratedMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -5936,15 +6385,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithProratedMinimum.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.GroupedWithMeteredMinimum.CompositePriceFilter.builder() + Price.GroupedWithProratedMinimum.CompositePriceFilter.builder() .field( - Price.GroupedWithMeteredMinimum.CompositePriceFilter.Field.PRICE_ID + Price.GroupedWithProratedMinimum.CompositePriceFilter.Field.PRICE_ID ) .operator( - Price.GroupedWithMeteredMinimum.CompositePriceFilter.Operator + Price.GroupedWithProratedMinimum.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -5972,6 +6421,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5993,30 +6443,14 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMeteredMinimumConfig( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() + .groupedWithProratedMinimumConfig( + Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() .groupingKey("x") - .minimumUnitAmount("minimum_unit_amount") - .pricingKey("pricing_key") - .addScalingFactor( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig - .ScalingFactor - .builder() - .scalingFactor("scaling_factor") - .scalingValue("scaling_value") - .build() - ) - .scalingKey("scaling_key") - .addUnitAmount( - Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig - .UnitAmount - .builder() - .pricingValue("pricing_value") - .unitAmount("unit_amount") - .build() - ) + .minimum("minimum") + .unitRate("unit_rate") .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6039,7 +6473,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMeteredMinimum.Metadata.builder() + Price.GroupedWithProratedMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6059,7 +6493,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -6067,6 +6501,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithProratedMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -6077,9 +6518,9 @@ internal class PriceTest { } @Test - fun ofGroupedWithMinMaxThresholds() { - val groupedWithMinMaxThresholds = - Price.GroupedWithMinMaxThresholds.builder() + fun ofGroupedWithMeteredMinimum() { + val groupedWithMeteredMinimum = + Price.GroupedWithMeteredMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6088,15 +6529,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.GroupedWithMinMaxThresholds.CompositePriceFilter.builder() - .field( - Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Field.PRICE_ID - ) + Price.GroupedWithMeteredMinimum.CompositePriceFilter.builder() + .field(Price.GroupedWithMeteredMinimum.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Operator.INCLUDES + Price.GroupedWithMeteredMinimum.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -6123,6 +6562,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6144,14 +6584,31 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMinMaxThresholdsConfig( - Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig.builder() + .groupedWithMeteredMinimumConfig( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() .groupingKey("x") - .maximumCharge("maximum_charge") - .minimumCharge("minimum_charge") - .perUnitRate("per_unit_rate") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6174,7 +6631,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMinMaxThresholds.Metadata.builder() + Price.GroupedWithMeteredMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6194,7 +6651,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -6202,9 +6659,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMeteredMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) + val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -6220,13 +6684,14 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty - assertThat(price.groupedWithMeteredMinimum()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).contains(groupedWithMinMaxThresholds) + assertThat(price.groupedWithMeteredMinimum()).contains(groupedWithMeteredMinimum) + assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty @@ -6234,17 +6699,19 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedWithMinMaxThresholdsRoundtrip() { + fun ofGroupedWithMeteredMinimumRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedWithMinMaxThresholds( - Price.GroupedWithMinMaxThresholds.builder() + Price.ofGroupedWithMeteredMinimum( + Price.GroupedWithMeteredMinimum.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6253,16 +6720,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithMeteredMinimum.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.GroupedWithMinMaxThresholds.CompositePriceFilter.builder() + Price.GroupedWithMeteredMinimum.CompositePriceFilter.builder() .field( - Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Field - .PRICE_ID + Price.GroupedWithMeteredMinimum.CompositePriceFilter.Field.PRICE_ID ) .operator( - Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Operator + Price.GroupedWithMeteredMinimum.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -6290,6 +6756,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6311,15 +6778,31 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedWithMinMaxThresholdsConfig( - Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig - .builder() + .groupedWithMeteredMinimumConfig( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() .groupingKey("x") - .maximumCharge("maximum_charge") - .minimumCharge("minimum_charge") - .perUnitRate("per_unit_rate") + .minimumUnitAmount("minimum_unit_amount") + .pricingKey("pricing_key") + .addScalingFactor( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig + .ScalingFactor + .builder() + .scalingFactor("scaling_factor") + .scalingValue("scaling_value") + .build() + ) + .scalingKey("scaling_key") + .addUnitAmount( + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig + .UnitAmount + .builder() + .pricingValue("pricing_value") + .unitAmount("unit_amount") + .build() + ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6342,7 +6825,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMinMaxThresholds.Metadata.builder() + Price.GroupedWithMeteredMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6362,7 +6845,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -6370,6 +6853,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMeteredMinimum.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -6380,9 +6870,9 @@ internal class PriceTest { } @Test - fun ofMatrixWithDisplayName() { - val matrixWithDisplayName = - Price.MatrixWithDisplayName.builder() + fun ofGroupedWithMinMaxThresholds() { + val groupedWithMinMaxThresholds = + Price.GroupedWithMinMaxThresholds.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6391,13 +6881,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) - .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.MatrixWithDisplayName.CompositePriceFilter.builder() - .field(Price.MatrixWithDisplayName.CompositePriceFilter.Field.PRICE_ID) + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.builder() + .field( + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Field.PRICE_ID + ) .operator( - Price.MatrixWithDisplayName.CompositePriceFilter.Operator.INCLUDES + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -6424,6 +6916,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6445,6 +6938,15 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedWithMinMaxThresholdsConfig( + Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig.builder() + .groupingKey("x") + .maximumCharge("maximum_charge") + .minimumCharge("minimum_charge") + .perUnitRate("per_unit_rate") + .build() + ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6452,19 +6954,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .matrixWithDisplayNameConfig( - Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() - .dimension("dimension") - .addUnitAmount( - Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.UnitAmount - .builder() - .dimensionValue("dimension_value") - .displayName("display_name") - .unitAmount("unit_amount") - .build() - ) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -6480,7 +6969,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithDisplayName.Metadata.builder() + Price.GroupedWithMinMaxThresholds.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6500,7 +6989,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -6508,9 +6997,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMinMaxThresholds.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) + val price = Price.ofGroupedWithMinMaxThresholds(groupedWithMinMaxThresholds) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -6526,31 +7022,34 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty assertThat(price.bulkWithProration()).isEmpty assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty - assertThat(price.groupedWithMinMaxThresholds()).isEmpty - assertThat(price.matrixWithDisplayName()).contains(matrixWithDisplayName) + assertThat(price.groupedWithMinMaxThresholds()).contains(groupedWithMinMaxThresholds) + assertThat(price.matrixWithDisplayName()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofMatrixWithDisplayNameRoundtrip() { + fun ofGroupedWithMinMaxThresholdsRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofMatrixWithDisplayName( - Price.MatrixWithDisplayName.builder() + Price.ofGroupedWithMinMaxThresholds( + Price.GroupedWithMinMaxThresholds.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6559,13 +7058,17 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) - .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) + .billingMode(Price.GroupedWithMinMaxThresholds.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedWithMinMaxThresholds.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.MatrixWithDisplayName.CompositePriceFilter.builder() - .field(Price.MatrixWithDisplayName.CompositePriceFilter.Field.PRICE_ID) + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.builder() + .field( + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Field + .PRICE_ID + ) .operator( - Price.MatrixWithDisplayName.CompositePriceFilter.Operator.INCLUDES + Price.GroupedWithMinMaxThresholds.CompositePriceFilter.Operator + .INCLUDES ) .addValue("string") .build() @@ -6592,6 +7095,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6613,6 +7117,16 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .groupedWithMinMaxThresholdsConfig( + Price.GroupedWithMinMaxThresholds.GroupedWithMinMaxThresholdsConfig + .builder() + .groupingKey("x") + .maximumCharge("maximum_charge") + .minimumCharge("minimum_charge") + .perUnitRate("per_unit_rate") + .build() + ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6620,19 +7134,6 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) - .matrixWithDisplayNameConfig( - Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() - .dimension("dimension") - .addUnitAmount( - Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.UnitAmount - .builder() - .dimensionValue("dimension_value") - .displayName("display_name") - .unitAmount("unit_amount") - .build() - ) - .build() - ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -6648,7 +7149,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithDisplayName.Metadata.builder() + Price.GroupedWithMinMaxThresholds.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6668,7 +7169,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMinMaxThresholds.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -6676,6 +7177,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedWithMinMaxThresholds.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -6686,9 +7194,9 @@ internal class PriceTest { } @Test - fun ofGroupedTieredPackage() { - val groupedTieredPackage = - Price.GroupedTieredPackage.builder() + fun ofMatrixWithDisplayName() { + val matrixWithDisplayName = + Price.MatrixWithDisplayName.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6697,12 +7205,14 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) + .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) + .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.GroupedTieredPackage.CompositePriceFilter.builder() - .field(Price.GroupedTieredPackage.CompositePriceFilter.Field.PRICE_ID) - .operator(Price.GroupedTieredPackage.CompositePriceFilter.Operator.INCLUDES) + Price.MatrixWithDisplayName.CompositePriceFilter.builder() + .field(Price.MatrixWithDisplayName.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.MatrixWithDisplayName.CompositePriceFilter.Operator.INCLUDES + ) .addValue("string") .build() ) @@ -6728,6 +7238,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6749,24 +7260,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedTieredPackageConfig( - Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() - .groupingKey("x") - .packageSize("package_size") - .addTier( - Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() - .perUnit("per_unit") - .tierLowerBound("tier_lower_bound") - .build() - ) - .addTier( - Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() - .perUnit("per_unit") - .tierLowerBound("tier_lower_bound") - .build() - ) - .build() - ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6774,6 +7268,19 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixWithDisplayNameConfig( + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() + .dimension("dimension") + .addUnitAmount( + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -6789,7 +7296,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPackage.Metadata.builder() + Price.MatrixWithDisplayName.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6809,7 +7316,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -6817,9 +7324,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithDisplayName.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofGroupedTieredPackage(groupedTieredPackage) + val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -6835,6 +7349,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -6842,24 +7357,26 @@ internal class PriceTest { assertThat(price.groupedWithProratedMinimum()).isEmpty assertThat(price.groupedWithMeteredMinimum()).isEmpty assertThat(price.groupedWithMinMaxThresholds()).isEmpty - assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.groupedTieredPackage()).contains(groupedTieredPackage) + assertThat(price.matrixWithDisplayName()).contains(matrixWithDisplayName) + assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofGroupedTieredPackageRoundtrip() { + fun ofMatrixWithDisplayNameRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofGroupedTieredPackage( - Price.GroupedTieredPackage.builder() + Price.ofMatrixWithDisplayName( + Price.MatrixWithDisplayName.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -6868,13 +7385,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) - .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) + .billingMode(Price.MatrixWithDisplayName.BillingMode.IN_ADVANCE) + .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.GroupedTieredPackage.CompositePriceFilter.builder() - .field(Price.GroupedTieredPackage.CompositePriceFilter.Field.PRICE_ID) + Price.MatrixWithDisplayName.CompositePriceFilter.builder() + .field(Price.MatrixWithDisplayName.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.GroupedTieredPackage.CompositePriceFilter.Operator.INCLUDES + Price.MatrixWithDisplayName.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -6901,6 +7418,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -6922,24 +7440,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .groupedTieredPackageConfig( - Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() - .groupingKey("x") - .packageSize("package_size") - .addTier( - Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() - .perUnit("per_unit") - .tierLowerBound("tier_lower_bound") - .build() - ) - .addTier( - Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() - .perUnit("per_unit") - .tierLowerBound("tier_lower_bound") - .build() - ) - .build() - ) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -6947,6 +7448,19 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .matrixWithDisplayNameConfig( + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() + .dimension("dimension") + .addUnitAmount( + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.UnitAmount + .builder() + .dimensionValue("dimension_value") + .displayName("display_name") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -6962,7 +7476,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPackage.Metadata.builder() + Price.MatrixWithDisplayName.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -6982,7 +7496,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -6990,6 +7504,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MatrixWithDisplayName.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -7000,9 +7521,9 @@ internal class PriceTest { } @Test - fun ofMaxGroupTieredPackage() { - val maxGroupTieredPackage = - Price.MaxGroupTieredPackage.builder() + fun ofGroupedTieredPackage() { + val groupedTieredPackage = + Price.GroupedTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -7011,14 +7532,12 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) - .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.MaxGroupTieredPackage.CompositePriceFilter.builder() - .field(Price.MaxGroupTieredPackage.CompositePriceFilter.Field.PRICE_ID) - .operator( - Price.MaxGroupTieredPackage.CompositePriceFilter.Operator.INCLUDES - ) + Price.GroupedTieredPackage.CompositePriceFilter.builder() + .field(Price.GroupedTieredPackage.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.GroupedTieredPackage.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -7044,6 +7563,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7065,31 +7585,32 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .item(ItemSlim.builder().id("id").name("name").build()) - .maxGroupTieredPackageConfig( - Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() + .groupedTieredPackageConfig( + Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() .groupingKey("x") .packageSize("package_size") .addTier( - Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier.builder() + Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") .build() ) .addTier( - Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier.builder() + Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") .build() ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -7105,7 +7626,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MaxGroupTieredPackage.Metadata.builder() + Price.GroupedTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7125,7 +7646,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -7133,9 +7654,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) + val price = Price.ofGroupedTieredPackage(groupedTieredPackage) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -7151,6 +7679,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -7159,23 +7688,25 @@ internal class PriceTest { assertThat(price.groupedWithMeteredMinimum()).isEmpty assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty - assertThat(price.groupedTieredPackage()).isEmpty - assertThat(price.maxGroupTieredPackage()).contains(maxGroupTieredPackage) + assertThat(price.groupedTieredPackage()).contains(groupedTieredPackage) + assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofMaxGroupTieredPackageRoundtrip() { + fun ofGroupedTieredPackageRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofMaxGroupTieredPackage( - Price.MaxGroupTieredPackage.builder() + Price.ofGroupedTieredPackage( + Price.GroupedTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -7184,13 +7715,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) - .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) + .billingMode(Price.GroupedTieredPackage.BillingMode.IN_ADVANCE) + .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.MaxGroupTieredPackage.CompositePriceFilter.builder() - .field(Price.MaxGroupTieredPackage.CompositePriceFilter.Field.PRICE_ID) + Price.GroupedTieredPackage.CompositePriceFilter.builder() + .field(Price.GroupedTieredPackage.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.MaxGroupTieredPackage.CompositePriceFilter.Operator.INCLUDES + Price.GroupedTieredPackage.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -7217,6 +7748,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7238,33 +7770,32 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .item(ItemSlim.builder().id("id").name("name").build()) - .maxGroupTieredPackageConfig( - Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() + .groupedTieredPackageConfig( + Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() .groupingKey("x") .packageSize("package_size") .addTier( - Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier - .builder() + Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") .build() ) .addTier( - Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier - .builder() + Price.GroupedTieredPackage.GroupedTieredPackageConfig.Tier.builder() + .perUnit("per_unit") .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") .build() ) .build() ) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -7280,7 +7811,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.MaxGroupTieredPackage.Metadata.builder() + Price.GroupedTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7300,7 +7831,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -7308,6 +7839,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.GroupedTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -7318,9 +7856,9 @@ internal class PriceTest { } @Test - fun ofScalableMatrixWithUnitPricing() { - val scalableMatrixWithUnitPricing = - Price.ScalableMatrixWithUnitPricing.builder() + fun ofMaxGroupTieredPackage() { + val maxGroupTieredPackage = + Price.MaxGroupTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -7329,16 +7867,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) - .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) + .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) + .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.builder() - .field( - Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Field.PRICE_ID - ) + Price.MaxGroupTieredPackage.CompositePriceFilter.builder() + .field(Price.MaxGroupTieredPackage.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Operator - .INCLUDES + Price.MaxGroupTieredPackage.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -7365,6 +7900,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7386,6 +7922,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7393,6 +7930,24 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .maxGroupTieredPackageConfig( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() + .groupingKey("x") + .packageSize("package_size") + .addTier( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier.builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -7408,7 +7963,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithUnitPricing.Metadata.builder() + Price.MaxGroupTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7428,35 +7983,24 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) + .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithUnitPricingConfig( - Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig - .builder() - .firstDimension("first_dimension") - .addMatrixScalingFactor( - Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig - .MatrixScalingFactor - .builder() - .firstDimensionValue("first_dimension_value") - .scalingFactor("scaling_factor") - .secondDimensionValue("second_dimension_value") - .build() - ) - .unitPrice("unit_price") - .prorate(true) - .secondDimension("second_dimension") - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MaxGroupTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -7472,6 +8016,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -7481,22 +8026,24 @@ internal class PriceTest { assertThat(price.groupedWithMinMaxThresholds()).isEmpty assertThat(price.matrixWithDisplayName()).isEmpty assertThat(price.groupedTieredPackage()).isEmpty - assertThat(price.maxGroupTieredPackage()).isEmpty - assertThat(price.scalableMatrixWithUnitPricing()).contains(scalableMatrixWithUnitPricing) + assertThat(price.maxGroupTieredPackage()).contains(maxGroupTieredPackage) + assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofScalableMatrixWithUnitPricingRoundtrip() { + fun ofMaxGroupTieredPackageRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofScalableMatrixWithUnitPricing( - Price.ScalableMatrixWithUnitPricing.builder() + Price.ofMaxGroupTieredPackage( + Price.MaxGroupTieredPackage.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -7505,17 +8052,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) - .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) + .billingMode(Price.MaxGroupTieredPackage.BillingMode.IN_ADVANCE) + .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.builder() - .field( - Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Field - .PRICE_ID - ) + Price.MaxGroupTieredPackage.CompositePriceFilter.builder() + .field(Price.MaxGroupTieredPackage.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Operator - .INCLUDES + Price.MaxGroupTieredPackage.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -7542,6 +8085,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -7563,6 +8107,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7570,6 +8115,26 @@ internal class PriceTest { .build() ) .item(ItemSlim.builder().id("id").name("name").build()) + .maxGroupTieredPackageConfig( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() + .groupingKey("x") + .packageSize("package_size") + .addTier( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .build() + ) .maximum( Maximum.builder() .addAppliesToPriceId("string") @@ -7585,7 +8150,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithUnitPricing.Metadata.builder() + Price.MaxGroupTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7605,33 +8170,21 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) + .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithUnitPricingConfig( - Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig - .builder() - .firstDimension("first_dimension") - .addMatrixScalingFactor( - Price.ScalableMatrixWithUnitPricing - .ScalableMatrixWithUnitPricingConfig - .MatrixScalingFactor - .builder() - .firstDimensionValue("first_dimension_value") - .scalingFactor("scaling_factor") - .secondDimensionValue("second_dimension_value") - .build() - ) - .unitPrice("unit_price") - .prorate(true) - .secondDimension("second_dimension") - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MaxGroupTieredPackage.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -7642,9 +8195,9 @@ internal class PriceTest { } @Test - fun ofScalableMatrixWithTieredPricing() { - val scalableMatrixWithTieredPricing = - Price.ScalableMatrixWithTieredPricing.builder() + fun ofScalableMatrixWithUnitPricing() { + val scalableMatrixWithUnitPricing = + Price.ScalableMatrixWithUnitPricing.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -7653,16 +8206,15 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) - .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) + .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.builder() + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.builder() .field( - Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Field - .PRICE_ID + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Field.PRICE_ID ) .operator( - Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Operator + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -7690,6 +8242,1069 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.ScalableMatrixWithUnitPricing.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .scalableMatrixWithUnitPricingConfig( + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig + .builder() + .firstDimension("first_dimension") + .addMatrixScalingFactor( + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .groupingKey("x") + .prorate(true) + .secondDimension("second_dimension") + .build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .licenseType( + Price.ScalableMatrixWithUnitPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .build() + + val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + + assertThat(price.unit()).isEmpty + assertThat(price.tiered()).isEmpty + assertThat(price.bulk()).isEmpty + assertThat(price.bulkWithFilters()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty + assertThat(price.thresholdTotalAmount()).isEmpty + assertThat(price.tieredPackage()).isEmpty + assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty + assertThat(price.tieredPackageWithMinimum()).isEmpty + assertThat(price.packageWithAllocation()).isEmpty + assertThat(price.unitWithPercent()).isEmpty + assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty + assertThat(price.tieredWithProration()).isEmpty + assertThat(price.unitWithProration()).isEmpty + assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty + assertThat(price.groupedWithProratedMinimum()).isEmpty + assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.matrixWithDisplayName()).isEmpty + assertThat(price.groupedTieredPackage()).isEmpty + assertThat(price.maxGroupTieredPackage()).isEmpty + assertThat(price.scalableMatrixWithUnitPricing()).contains(scalableMatrixWithUnitPricing) + assertThat(price.scalableMatrixWithTieredPricing()).isEmpty + assertThat(price.cumulativeGroupedBulk()).isEmpty + assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty + assertThat(price.minimumComposite()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty + } + + @Test + fun ofScalableMatrixWithUnitPricingRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofScalableMatrixWithUnitPricing( + Price.ScalableMatrixWithUnitPricing.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.ScalableMatrixWithUnitPricing.BillingMode.IN_ADVANCE) + .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.builder() + .field( + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Field + .PRICE_ID + ) + .operator( + Price.ScalableMatrixWithUnitPricing.CompositePriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .licenseTypeId("license_type_id") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.ScalableMatrixWithUnitPricing.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .scalableMatrixWithUnitPricingConfig( + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig + .builder() + .firstDimension("first_dimension") + .addMatrixScalingFactor( + Price.ScalableMatrixWithUnitPricing + .ScalableMatrixWithUnitPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .unitPrice("unit_price") + .groupingKey("x") + .prorate(true) + .secondDimension("second_dimension") + .build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .licenseType( + Price.ScalableMatrixWithUnitPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + + @Test + fun ofScalableMatrixWithTieredPricing() { + val scalableMatrixWithTieredPricing = + Price.ScalableMatrixWithTieredPricing.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) + .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.builder() + .field( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Field + .PRICE_ID + ) + .operator( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .licenseTypeId("license_type_id") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.ScalableMatrixWithTieredPricing.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .scalableMatrixWithTieredPricingConfig( + Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig + .builder() + .firstDimension("first_dimension") + .addMatrixScalingFactor( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") + .build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .licenseType( + Price.ScalableMatrixWithTieredPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .build() + + val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) + + assertThat(price.unit()).isEmpty + assertThat(price.tiered()).isEmpty + assertThat(price.bulk()).isEmpty + assertThat(price.bulkWithFilters()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty + assertThat(price.thresholdTotalAmount()).isEmpty + assertThat(price.tieredPackage()).isEmpty + assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty + assertThat(price.tieredPackageWithMinimum()).isEmpty + assertThat(price.packageWithAllocation()).isEmpty + assertThat(price.unitWithPercent()).isEmpty + assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty + assertThat(price.tieredWithProration()).isEmpty + assertThat(price.unitWithProration()).isEmpty + assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty + assertThat(price.groupedWithProratedMinimum()).isEmpty + assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.matrixWithDisplayName()).isEmpty + assertThat(price.groupedTieredPackage()).isEmpty + assertThat(price.maxGroupTieredPackage()).isEmpty + assertThat(price.scalableMatrixWithUnitPricing()).isEmpty + assertThat(price.scalableMatrixWithTieredPricing()) + .contains(scalableMatrixWithTieredPricing) + assertThat(price.cumulativeGroupedBulk()).isEmpty + assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty + assertThat(price.minimumComposite()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty + } + + @Test + fun ofScalableMatrixWithTieredPricingRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofScalableMatrixWithTieredPricing( + Price.ScalableMatrixWithTieredPricing.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) + .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.builder() + .field( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Field + .PRICE_ID + ) + .operator( + Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Operator + .INCLUDES + ) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .licenseTypeId("license_type_id") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.ScalableMatrixWithTieredPricing.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .scalableMatrixWithTieredPricingConfig( + Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig + .builder() + .firstDimension("first_dimension") + .addMatrixScalingFactor( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .MatrixScalingFactor + .builder() + .firstDimensionValue("first_dimension_value") + .scalingFactor("scaling_factor") + .secondDimensionValue("second_dimension_value") + .build() + ) + .addTier( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .addTier( + Price.ScalableMatrixWithTieredPricing + .ScalableMatrixWithTieredPricingConfig + .Tier + .builder() + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .secondDimension("second_dimension") + .build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .licenseType( + Price.ScalableMatrixWithTieredPricing.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + + @Test + fun ofCumulativeGroupedBulk() { + val cumulativeGroupedBulk = + Price.CumulativeGroupedBulk.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) + .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.CumulativeGroupedBulk.CompositePriceFilter.builder() + .field(Price.CumulativeGroupedBulk.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.CumulativeGroupedBulk.CompositePriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .licenseTypeId("license_type_id") + .build() + ) + .cumulativeGroupedBulkConfig( + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() + .addDimensionValue( + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.CumulativeGroupedBulk.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .licenseType( + Price.CumulativeGroupedBulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .build() + + val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + + assertThat(price.unit()).isEmpty + assertThat(price.tiered()).isEmpty + assertThat(price.bulk()).isEmpty + assertThat(price.bulkWithFilters()).isEmpty + assertThat(price.package_()).isEmpty + assertThat(price.matrix()).isEmpty + assertThat(price.thresholdTotalAmount()).isEmpty + assertThat(price.tieredPackage()).isEmpty + assertThat(price.tieredWithMinimum()).isEmpty + assertThat(price.groupedTiered()).isEmpty + assertThat(price.tieredPackageWithMinimum()).isEmpty + assertThat(price.packageWithAllocation()).isEmpty + assertThat(price.unitWithPercent()).isEmpty + assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty + assertThat(price.tieredWithProration()).isEmpty + assertThat(price.unitWithProration()).isEmpty + assertThat(price.groupedAllocation()).isEmpty + assertThat(price.bulkWithProration()).isEmpty + assertThat(price.groupedWithProratedMinimum()).isEmpty + assertThat(price.groupedWithMeteredMinimum()).isEmpty + assertThat(price.groupedWithMinMaxThresholds()).isEmpty + assertThat(price.matrixWithDisplayName()).isEmpty + assertThat(price.groupedTieredPackage()).isEmpty + assertThat(price.maxGroupTieredPackage()).isEmpty + assertThat(price.scalableMatrixWithUnitPricing()).isEmpty + assertThat(price.scalableMatrixWithTieredPricing()).isEmpty + assertThat(price.cumulativeGroupedBulk()).contains(cumulativeGroupedBulk) + assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty + assertThat(price.minimumComposite()).isEmpty + assertThat(price.percent()).isEmpty + assertThat(price.eventOutput()).isEmpty + } + + @Test + fun ofCumulativeGroupedBulkRoundtrip() { + val jsonMapper = jsonMapper() + val price = + Price.ofCumulativeGroupedBulk( + Price.CumulativeGroupedBulk.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) + .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.CumulativeGroupedBulk.CompositePriceFilter.builder() + .field(Price.CumulativeGroupedBulk.CompositePriceFilter.Field.PRICE_ID) + .operator( + Price.CumulativeGroupedBulk.CompositePriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .licenseTypeId("license_type_id") + .build() + ) + .cumulativeGroupedBulkConfig( + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() + .addDimensionValue( + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig + .DimensionValue + .builder() + .groupingKey("x") + .tierLowerBound("tier_lower_bound") + .unitAmount("unit_amount") + .build() + ) + .group("group") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .addFilter( + PercentageDiscount.Filter.builder() + .field(PercentageDiscount.Filter.Field.PRICE_ID) + .operator(PercentageDiscount.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .item(ItemSlim.builder().id("id").name("name").build()) + .maximum( + Maximum.builder() + .addAppliesToPriceId("string") + .addFilter( + Maximum.Filter.builder() + .field(Maximum.Filter.Field.PRICE_ID) + .operator(Maximum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + Price.CumulativeGroupedBulk.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + Minimum.builder() + .addAppliesToPriceId("string") + .addFilter( + Minimum.Filter.builder() + .field(Minimum.Filter.Field.PRICE_ID) + .operator(Minimum.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .planPhaseOrder(0L) + .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) + .replacesPriceId("replaces_price_id") + .dimensionalPriceConfiguration( + DimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .licenseType( + Price.CumulativeGroupedBulk.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) + .build() + ) + + val roundtrippedPrice = + jsonMapper.readValue(jsonMapper.writeValueAsString(price), jacksonTypeRef()) + + assertThat(roundtrippedPrice).isEqualTo(price) + } + + @Test + fun ofCumulativeGroupedAllocation() { + val cumulativeGroupedAllocation = + Price.CumulativeGroupedAllocation.builder() + .id("id") + .billableMetric(BillableMetricTiny.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .billingMode(Price.CumulativeGroupedAllocation.BillingMode.IN_ADVANCE) + .cadence(Price.CumulativeGroupedAllocation.Cadence.ONE_TIME) + .addCompositePriceFilter( + Price.CumulativeGroupedAllocation.CompositePriceFilter.builder() + .field( + Price.CumulativeGroupedAllocation.CompositePriceFilter.Field.PRICE_ID + ) + .operator( + Price.CumulativeGroupedAllocation.CompositePriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + Allocation.builder() + .allowsRollover(true) + .currency("currency") + .customExpiration( + CustomExpiration.builder() + .duration(0L) + .durationUnit(CustomExpiration.DurationUnit.DAY) + .build() + ) + .addFilter( + Allocation.Filter.builder() + .field(Allocation.Filter.Field.PRICE_ID) + .operator(Allocation.Filter.Operator.INCLUDES) + .addValue("string") + .build() + ) + .licenseTypeId("license_type_id") + .build() + ) + .cumulativeGroupedAllocationConfig( + Price.CumulativeGroupedAllocation.CumulativeGroupedAllocationConfig.builder() + .cumulativeAllocation("cumulative_allocation") + .groupAllocation("group_allocation") + .groupingKey("x") + .unitAmount("unit_amount") .build() ) .currency("currency") @@ -7711,6 +9326,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7733,7 +9349,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithTieredPricing.Metadata.builder() + Price.CumulativeGroupedAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7753,52 +9369,24 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) + .priceType(Price.CumulativeGroupedAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithTieredPricingConfig( - Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig - .builder() - .firstDimension("first_dimension") - .addMatrixScalingFactor( - Price.ScalableMatrixWithTieredPricing - .ScalableMatrixWithTieredPricingConfig - .MatrixScalingFactor - .builder() - .firstDimensionValue("first_dimension_value") - .scalingFactor("scaling_factor") - .secondDimensionValue("second_dimension_value") - .build() - ) - .addTier( - Price.ScalableMatrixWithTieredPricing - .ScalableMatrixWithTieredPricingConfig - .Tier - .builder() - .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") - .build() - ) - .addTier( - Price.ScalableMatrixWithTieredPricing - .ScalableMatrixWithTieredPricingConfig - .Tier - .builder() - .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") - .build() - ) - .secondDimension("second_dimension") - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) + val price = Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -7814,6 +9402,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -7825,21 +9414,22 @@ internal class PriceTest { assertThat(price.groupedTieredPackage()).isEmpty assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty - assertThat(price.scalableMatrixWithTieredPricing()) - .contains(scalableMatrixWithTieredPricing) + assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.cumulativeGroupedAllocation()).contains(cumulativeGroupedAllocation) + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofScalableMatrixWithTieredPricingRoundtrip() { + fun ofCumulativeGroupedAllocationRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofScalableMatrixWithTieredPricing( - Price.ScalableMatrixWithTieredPricing.builder() + Price.ofCumulativeGroupedAllocation( + Price.CumulativeGroupedAllocation.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -7848,16 +9438,16 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.ScalableMatrixWithTieredPricing.BillingMode.IN_ADVANCE) - .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) + .billingMode(Price.CumulativeGroupedAllocation.BillingMode.IN_ADVANCE) + .cadence(Price.CumulativeGroupedAllocation.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.builder() + Price.CumulativeGroupedAllocation.CompositePriceFilter.builder() .field( - Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Field + Price.CumulativeGroupedAllocation.CompositePriceFilter.Field .PRICE_ID ) .operator( - Price.ScalableMatrixWithTieredPricing.CompositePriceFilter.Operator + Price.CumulativeGroupedAllocation.CompositePriceFilter.Operator .INCLUDES ) .addValue("string") @@ -7885,6 +9475,16 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") + .build() + ) + .cumulativeGroupedAllocationConfig( + Price.CumulativeGroupedAllocation.CumulativeGroupedAllocationConfig + .builder() + .cumulativeAllocation("cumulative_allocation") + .groupAllocation("group_allocation") + .groupingKey("x") + .unitAmount("unit_amount") .build() ) .currency("currency") @@ -7906,6 +9506,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -7928,7 +9529,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithTieredPricing.Metadata.builder() + Price.CumulativeGroupedAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -7948,49 +9549,21 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) + .priceType(Price.CumulativeGroupedAllocation.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") - .scalableMatrixWithTieredPricingConfig( - Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig - .builder() - .firstDimension("first_dimension") - .addMatrixScalingFactor( - Price.ScalableMatrixWithTieredPricing - .ScalableMatrixWithTieredPricingConfig - .MatrixScalingFactor - .builder() - .firstDimensionValue("first_dimension_value") - .scalingFactor("scaling_factor") - .secondDimensionValue("second_dimension_value") - .build() - ) - .addTier( - Price.ScalableMatrixWithTieredPricing - .ScalableMatrixWithTieredPricingConfig - .Tier - .builder() - .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") - .build() - ) - .addTier( - Price.ScalableMatrixWithTieredPricing - .ScalableMatrixWithTieredPricingConfig - .Tier - .builder() - .tierLowerBound("tier_lower_bound") - .unitAmount("unit_amount") - .build() - ) - .secondDimension("second_dimension") - .build() - ) .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.CumulativeGroupedAllocation.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8001,9 +9574,9 @@ internal class PriceTest { } @Test - fun ofCumulativeGroupedBulk() { - val cumulativeGroupedBulk = - Price.CumulativeGroupedBulk.builder() + fun ofDailyCreditAllowance() { + val dailyCreditAllowance = + Price.DailyCreditAllowance.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -8012,14 +9585,12 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) - .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .billingMode(Price.DailyCreditAllowance.BillingMode.IN_ADVANCE) + .cadence(Price.DailyCreditAllowance.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.CumulativeGroupedBulk.CompositePriceFilter.builder() - .field(Price.CumulativeGroupedBulk.CompositePriceFilter.Field.PRICE_ID) - .operator( - Price.CumulativeGroupedBulk.CompositePriceFilter.Operator.INCLUDES - ) + Price.DailyCreditAllowance.CompositePriceFilter.builder() + .field(Price.DailyCreditAllowance.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.DailyCreditAllowance.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8045,22 +9616,25 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) - .cumulativeGroupedBulkConfig( - Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() - .addDimensionValue( - Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.DimensionValue + .currency("currency") + .dailyCreditAllowanceConfig( + Price.DailyCreditAllowance.DailyCreditAllowanceConfig.builder() + .dailyAllowance("daily_allowance") + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .eventDayProperty("x") + .addMatrixValue( + Price.DailyCreditAllowance.DailyCreditAllowanceConfig.MatrixValue .builder() - .groupingKey("x") - .tierLowerBound("tier_lower_bound") + .addDimensionValue("string") .unitAmount("unit_amount") .build() ) - .group("group") .build() ) - .currency("currency") .discount( PercentageDiscount.builder() .discountType(PercentageDiscount.DiscountType.PERCENTAGE) @@ -8079,6 +9653,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8101,7 +9676,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedBulk.Metadata.builder() + Price.DailyCreditAllowance.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -8121,7 +9696,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) + .priceType(Price.DailyCreditAllowance.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -8129,9 +9704,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.DailyCreditAllowance.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) + val price = Price.ofDailyCreditAllowance(dailyCreditAllowance) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -8147,6 +9729,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -8159,19 +9742,21 @@ internal class PriceTest { assertThat(price.maxGroupTieredPackage()).isEmpty assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty - assertThat(price.cumulativeGroupedBulk()).contains(cumulativeGroupedBulk) + assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).contains(dailyCreditAllowance) + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofCumulativeGroupedBulkRoundtrip() { + fun ofDailyCreditAllowanceRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofCumulativeGroupedBulk( - Price.CumulativeGroupedBulk.builder() + Price.ofDailyCreditAllowance( + Price.DailyCreditAllowance.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -8180,13 +9765,13 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.CumulativeGroupedBulk.BillingMode.IN_ADVANCE) - .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) + .billingMode(Price.DailyCreditAllowance.BillingMode.IN_ADVANCE) + .cadence(Price.DailyCreditAllowance.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.CumulativeGroupedBulk.CompositePriceFilter.builder() - .field(Price.CumulativeGroupedBulk.CompositePriceFilter.Field.PRICE_ID) + Price.DailyCreditAllowance.CompositePriceFilter.builder() + .field(Price.DailyCreditAllowance.CompositePriceFilter.Field.PRICE_ID) .operator( - Price.CumulativeGroupedBulk.CompositePriceFilter.Operator.INCLUDES + Price.DailyCreditAllowance.CompositePriceFilter.Operator.INCLUDES ) .addValue("string") .build() @@ -8213,23 +9798,25 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) - .cumulativeGroupedBulkConfig( - Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() - .addDimensionValue( - Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig - .DimensionValue + .currency("currency") + .dailyCreditAllowanceConfig( + Price.DailyCreditAllowance.DailyCreditAllowanceConfig.builder() + .dailyAllowance("daily_allowance") + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .eventDayProperty("x") + .addMatrixValue( + Price.DailyCreditAllowance.DailyCreditAllowanceConfig.MatrixValue .builder() - .groupingKey("x") - .tierLowerBound("tier_lower_bound") + .addDimensionValue("string") .unitAmount("unit_amount") .build() ) - .group("group") .build() ) - .currency("currency") .discount( PercentageDiscount.builder() .discountType(PercentageDiscount.DiscountType.PERCENTAGE) @@ -8248,6 +9835,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8270,7 +9858,7 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedBulk.Metadata.builder() + Price.DailyCreditAllowance.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -8290,7 +9878,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) + .priceType(Price.DailyCreditAllowance.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -8298,6 +9886,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.DailyCreditAllowance.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8308,9 +9903,9 @@ internal class PriceTest { } @Test - fun ofCumulativeGroupedAllocation() { - val cumulativeGroupedAllocation = - Price.CumulativeGroupedAllocation.builder() + fun ofMeteredAllowance() { + val meteredAllowance = + Price.MeteredAllowance.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -8319,16 +9914,12 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.CumulativeGroupedAllocation.BillingMode.IN_ADVANCE) - .cadence(Price.CumulativeGroupedAllocation.Cadence.ONE_TIME) + .billingMode(Price.MeteredAllowance.BillingMode.IN_ADVANCE) + .cadence(Price.MeteredAllowance.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.CumulativeGroupedAllocation.CompositePriceFilter.builder() - .field( - Price.CumulativeGroupedAllocation.CompositePriceFilter.Field.PRICE_ID - ) - .operator( - Price.CumulativeGroupedAllocation.CompositePriceFilter.Operator.INCLUDES - ) + Price.MeteredAllowance.CompositePriceFilter.builder() + .field(Price.MeteredAllowance.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.MeteredAllowance.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8354,14 +9945,7 @@ internal class PriceTest { .addValue("string") .build() ) - .build() - ) - .cumulativeGroupedAllocationConfig( - Price.CumulativeGroupedAllocation.CumulativeGroupedAllocationConfig.builder() - .cumulativeAllocation("cumulative_allocation") - .groupAllocation("group_allocation") - .groupingKey("x") - .unitAmount("unit_amount") + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -8383,6 +9967,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8405,10 +9990,20 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedAllocation.Metadata.builder() + Price.MeteredAllowance.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .meteredAllowanceConfig( + Price.MeteredAllowance.MeteredAllowanceConfig.builder() + .allowanceGroupingValue("x") + .consumptionGroupingValue("x") + .groupingKey("x") + .unitAmount("unit_amount") + .allowanceDisplayName("x") + .consumptionDisplayName("x") + .build() + ) .minimum( Minimum.builder() .addAppliesToPriceId("string") @@ -8425,7 +10020,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedAllocation.PriceType.USAGE_PRICE) + .priceType(Price.MeteredAllowance.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -8433,9 +10028,16 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MeteredAllowance.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() - val price = Price.ofCumulativeGroupedAllocation(cumulativeGroupedAllocation) + val price = Price.ofMeteredAllowance(meteredAllowance) assertThat(price.unit()).isEmpty assertThat(price.tiered()).isEmpty @@ -8451,6 +10053,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -8464,18 +10067,20 @@ internal class PriceTest { assertThat(price.scalableMatrixWithUnitPricing()).isEmpty assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty - assertThat(price.cumulativeGroupedAllocation()).contains(cumulativeGroupedAllocation) + assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).contains(meteredAllowance) assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty } @Test - fun ofCumulativeGroupedAllocationRoundtrip() { + fun ofMeteredAllowanceRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofCumulativeGroupedAllocation( - Price.CumulativeGroupedAllocation.builder() + Price.ofMeteredAllowance( + Price.MeteredAllowance.builder() .id("id") .billableMetric(BillableMetricTiny.builder().id("id").build()) .billingCycleConfiguration( @@ -8484,18 +10089,12 @@ internal class PriceTest { .durationUnit(BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .billingMode(Price.CumulativeGroupedAllocation.BillingMode.IN_ADVANCE) - .cadence(Price.CumulativeGroupedAllocation.Cadence.ONE_TIME) + .billingMode(Price.MeteredAllowance.BillingMode.IN_ADVANCE) + .cadence(Price.MeteredAllowance.Cadence.ONE_TIME) .addCompositePriceFilter( - Price.CumulativeGroupedAllocation.CompositePriceFilter.builder() - .field( - Price.CumulativeGroupedAllocation.CompositePriceFilter.Field - .PRICE_ID - ) - .operator( - Price.CumulativeGroupedAllocation.CompositePriceFilter.Operator - .INCLUDES - ) + Price.MeteredAllowance.CompositePriceFilter.builder() + .field(Price.MeteredAllowance.CompositePriceFilter.Field.PRICE_ID) + .operator(Price.MeteredAllowance.CompositePriceFilter.Operator.INCLUDES) .addValue("string") .build() ) @@ -8521,15 +10120,7 @@ internal class PriceTest { .addValue("string") .build() ) - .build() - ) - .cumulativeGroupedAllocationConfig( - Price.CumulativeGroupedAllocation.CumulativeGroupedAllocationConfig - .builder() - .cumulativeAllocation("cumulative_allocation") - .groupAllocation("group_allocation") - .groupingKey("x") - .unitAmount("unit_amount") + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -8551,6 +10142,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8573,10 +10165,20 @@ internal class PriceTest { ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedAllocation.Metadata.builder() + Price.MeteredAllowance.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) + .meteredAllowanceConfig( + Price.MeteredAllowance.MeteredAllowanceConfig.builder() + .allowanceGroupingValue("x") + .consumptionGroupingValue("x") + .groupingKey("x") + .unitAmount("unit_amount") + .allowanceDisplayName("x") + .consumptionDisplayName("x") + .build() + ) .minimum( Minimum.builder() .addAppliesToPriceId("string") @@ -8593,7 +10195,7 @@ internal class PriceTest { .minimumAmount("minimum_amount") .name("name") .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedAllocation.PriceType.USAGE_PRICE) + .priceType(Price.MeteredAllowance.PriceType.USAGE_PRICE) .replacesPriceId("replaces_price_id") .dimensionalPriceConfiguration( DimensionalPriceConfiguration.builder() @@ -8601,6 +10203,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MeteredAllowance.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8653,6 +10262,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -8674,6 +10284,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8730,6 +10341,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MinimumComposite.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofMinimumComposite(minimumComposite) @@ -8748,6 +10366,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -8762,6 +10381,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).contains(minimumComposite) assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).isEmpty @@ -8812,6 +10433,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -8833,6 +10455,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -8889,6 +10512,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.MinimumComposite.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -8941,6 +10571,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -8962,6 +10593,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9013,6 +10645,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Percent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofPercent(percent) @@ -9031,6 +10670,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -9045,6 +10685,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).contains(percent) assertThat(price.eventOutput()).isEmpty @@ -9095,6 +10737,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9116,6 +10759,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9167,6 +10811,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.Percent.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) @@ -9219,6 +10870,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9247,6 +10899,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9297,6 +10950,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.EventOutput.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() val price = Price.ofEventOutput(eventOutput) @@ -9315,6 +10975,7 @@ internal class PriceTest { assertThat(price.packageWithAllocation()).isEmpty assertThat(price.unitWithPercent()).isEmpty assertThat(price.matrixWithAllocation()).isEmpty + assertThat(price.matrixWithThresholdDiscounts()).isEmpty assertThat(price.tieredWithProration()).isEmpty assertThat(price.unitWithProration()).isEmpty assertThat(price.groupedAllocation()).isEmpty @@ -9329,6 +10990,8 @@ internal class PriceTest { assertThat(price.scalableMatrixWithTieredPricing()).isEmpty assertThat(price.cumulativeGroupedBulk()).isEmpty assertThat(price.cumulativeGroupedAllocation()).isEmpty + assertThat(price.dailyCreditAllowance()).isEmpty + assertThat(price.meteredAllowance()).isEmpty assertThat(price.minimumComposite()).isEmpty assertThat(price.percent()).isEmpty assertThat(price.eventOutput()).contains(eventOutput) @@ -9379,6 +11042,7 @@ internal class PriceTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -9407,6 +11071,7 @@ internal class PriceTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -9457,6 +11122,13 @@ internal class PriceTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.EventOutput.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) 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 0f2cac109..77ddbab51 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 @@ -168,6 +168,9 @@ internal class SubscriptionChangeApplyResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -461,6 +464,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -489,6 +493,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -552,6 +557,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -650,6 +662,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -678,6 +691,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -741,10 +755,22 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1132,6 +1158,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1171,6 +1198,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1255,6 +1283,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1746,6 +1781,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1785,6 +1821,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1869,6 +1906,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2157,6 +2201,9 @@ internal class SubscriptionChangeApplyResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -2438,6 +2485,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2463,6 +2511,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2521,6 +2570,13 @@ internal class SubscriptionChangeApplyResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2610,6 +2666,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2635,6 +2692,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2693,10 +2751,22 @@ internal class SubscriptionChangeApplyResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -3056,6 +3126,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3088,6 +3159,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3172,6 +3244,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3625,6 +3704,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3657,6 +3737,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3741,6 +3822,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4036,6 +4124,9 @@ internal class SubscriptionChangeApplyResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -4329,6 +4420,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4357,6 +4449,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4420,6 +4513,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -4518,6 +4618,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4546,6 +4647,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4609,10 +4711,22 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -5000,6 +5114,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5039,6 +5154,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5123,6 +5239,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -5614,6 +5737,7 @@ internal class SubscriptionChangeApplyResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5653,6 +5777,7 @@ internal class SubscriptionChangeApplyResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5737,6 +5862,13 @@ internal class SubscriptionChangeApplyResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) 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 f495f5643..050087e16 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 @@ -168,6 +168,9 @@ internal class SubscriptionChangeCancelResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -461,6 +464,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -489,6 +493,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -552,6 +557,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -650,6 +662,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -678,6 +691,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -741,10 +755,22 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1132,6 +1158,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1171,6 +1198,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1255,6 +1283,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1746,6 +1781,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1785,6 +1821,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1869,6 +1906,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2157,6 +2201,9 @@ internal class SubscriptionChangeCancelResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -2438,6 +2485,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2463,6 +2511,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2521,6 +2570,13 @@ internal class SubscriptionChangeCancelResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2610,6 +2666,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2635,6 +2692,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2693,10 +2751,22 @@ internal class SubscriptionChangeCancelResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -3056,6 +3126,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3088,6 +3159,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3172,6 +3244,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3625,6 +3704,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3657,6 +3737,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3741,6 +3822,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4036,6 +4124,9 @@ internal class SubscriptionChangeCancelResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -4329,6 +4420,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4357,6 +4449,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4420,6 +4513,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -4518,6 +4618,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4546,6 +4647,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4609,10 +4711,22 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -5000,6 +5114,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5039,6 +5154,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5123,6 +5239,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -5614,6 +5737,7 @@ internal class SubscriptionChangeCancelResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5653,6 +5777,7 @@ internal class SubscriptionChangeCancelResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5737,6 +5862,13 @@ internal class SubscriptionChangeCancelResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) 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 5254d6977..70f982b97 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 @@ -168,6 +168,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -461,6 +464,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -489,6 +493,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -552,6 +557,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -650,6 +662,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -678,6 +691,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -741,10 +755,22 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1132,6 +1158,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1171,6 +1198,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1255,6 +1283,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -1746,6 +1781,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1785,6 +1821,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1869,6 +1906,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -2157,6 +2201,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -2438,6 +2485,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2463,6 +2511,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2521,6 +2570,13 @@ internal class SubscriptionChangeRetrieveResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2610,6 +2666,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2635,6 +2692,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2693,10 +2751,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -3056,6 +3126,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3088,6 +3159,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3172,6 +3244,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -3625,6 +3704,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -3657,6 +3737,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -3741,6 +3822,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -4036,6 +4124,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -4329,6 +4420,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4357,6 +4449,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4420,6 +4513,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -4518,6 +4618,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -4546,6 +4647,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -4609,10 +4711,22 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -5000,6 +5114,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5039,6 +5154,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5123,6 +5239,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) @@ -5614,6 +5737,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -5653,6 +5777,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -5737,6 +5862,13 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .quantity(1.0) 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 fa2ac6848..8302073d1 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 @@ -65,6 +65,12 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -79,6 +85,11 @@ internal class SubscriptionCreateParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -124,6 +135,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -228,6 +240,12 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -242,6 +260,11 @@ internal class SubscriptionCreateParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -286,6 +309,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -359,6 +383,12 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -373,6 +403,11 @@ internal class SubscriptionCreateParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -420,6 +455,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -524,6 +560,12 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -538,6 +580,11 @@ internal class SubscriptionCreateParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -584,6 +631,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -656,6 +704,12 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -670,6 +724,11 @@ internal class SubscriptionCreateParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -715,6 +774,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -826,6 +886,12 @@ internal class SubscriptionCreateParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -840,6 +906,11 @@ internal class SubscriptionCreateParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -884,6 +955,7 @@ internal class SubscriptionCreateParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) 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 0ae21fa3e..4c93b6908 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 @@ -76,6 +76,7 @@ internal class SubscriptionFetchCostsResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -104,6 +105,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -167,6 +169,13 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -238,6 +247,7 @@ internal class SubscriptionFetchCostsResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -263,6 +273,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -321,6 +332,13 @@ internal class SubscriptionFetchCostsResponseTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_id") @@ -403,6 +421,7 @@ internal class SubscriptionFetchCostsResponseTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -431,6 +450,7 @@ internal class SubscriptionFetchCostsResponseTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -494,6 +514,13 @@ internal class SubscriptionFetchCostsResponseTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .priceId("price_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 4494ff91e..10b2d2e3c 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 @@ -16,7 +16,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .subscriptionId("subscription_id") .addAdd( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -37,12 +37,18 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -52,6 +58,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -96,6 +107,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -109,7 +121,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -134,7 +146,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .allowInvoiceCreditOrVoid(true) @@ -144,7 +156,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition.builder() @@ -152,15 +164,20 @@ internal class SubscriptionPriceIntervalsParamsTest { .quantity(5L) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) .addEditAdjustment( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .build() @@ -183,7 +200,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .subscriptionId("subscription_id") .addAdd( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -204,12 +221,18 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -220,6 +243,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -266,6 +294,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -279,7 +308,7 @@ internal class SubscriptionPriceIntervalsParamsTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -304,7 +333,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .allowInvoiceCreditOrVoid(true) @@ -314,7 +343,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition @@ -323,15 +352,20 @@ internal class SubscriptionPriceIntervalsParamsTest { .quantity(5L) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) .addEditAdjustment( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .build() @@ -341,7 +375,7 @@ internal class SubscriptionPriceIntervalsParamsTest { assertThat(body.add().getOrNull()) .containsExactly( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -362,12 +396,18 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -377,6 +417,11 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -421,6 +466,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -435,7 +481,7 @@ internal class SubscriptionPriceIntervalsParamsTest { assertThat(body.addAdjustments().getOrNull()) .containsExactly( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -460,7 +506,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) assertThat(body.allowInvoiceCreditOrVoid()).contains(true) @@ -471,7 +517,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition.builder() @@ -479,7 +525,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .quantity(5L) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) @@ -487,8 +538,8 @@ internal class SubscriptionPriceIntervalsParamsTest { .containsExactly( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) } 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 c39d53054..c26c83ea0 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 @@ -67,6 +67,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -81,6 +87,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -126,6 +138,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -221,6 +234,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -235,6 +254,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -279,6 +304,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -366,6 +392,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -380,6 +412,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -427,6 +465,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -522,6 +561,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -536,6 +581,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -582,6 +634,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -655,6 +708,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -669,6 +728,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -714,6 +779,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -812,6 +878,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -826,6 +898,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -870,6 +948,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) 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 decfe4eee..d51688c43 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 @@ -151,6 +151,7 @@ internal class SubscriptionTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -421,6 +422,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -444,6 +446,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -500,6 +503,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -584,6 +594,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -607,6 +618,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -663,10 +675,22 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -820,6 +844,7 @@ internal class SubscriptionTest { Customer.PaymentConfiguration.PaymentProvider.ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1093,6 +1118,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1114,6 +1140,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1170,6 +1197,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -1249,6 +1283,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1270,6 +1305,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1326,10 +1362,22 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(subscription.redeemedCoupon()) @@ -1492,6 +1540,7 @@ internal class SubscriptionTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1762,6 +1811,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1785,6 +1835,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1841,6 +1892,13 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -1925,6 +1983,7 @@ internal class SubscriptionTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1948,6 +2007,7 @@ internal class SubscriptionTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2004,10 +2064,22 @@ internal class SubscriptionTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( 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 93ca1b208..4af35dcbc 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 @@ -164,6 +164,9 @@ internal class SubscriptionsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -457,6 +460,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -485,6 +489,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -548,6 +553,13 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -646,6 +658,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -674,6 +687,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -737,10 +751,22 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -906,6 +932,9 @@ internal class SubscriptionsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -1187,6 +1216,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1212,6 +1242,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1270,6 +1301,13 @@ internal class SubscriptionsTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -1359,6 +1397,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1384,6 +1423,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -1442,10 +1482,22 @@ internal class SubscriptionsTest { .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( @@ -1622,6 +1674,9 @@ internal class SubscriptionsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken( + "default_shared_payment_token" + ) .addExcludedPaymentMethodType("string") .build() ) @@ -1915,6 +1970,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -1943,6 +1999,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2006,6 +2063,13 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .product( @@ -2104,6 +2168,7 @@ internal class SubscriptionsTest { .addValue("string") .build() ) + .licenseTypeId("license_type_id") .build() ) .currency("currency") @@ -2132,6 +2197,7 @@ internal class SubscriptionsTest { ) .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( BillingCycleConfiguration.builder() .duration(0L) @@ -2195,10 +2261,22 @@ internal class SubscriptionsTest { ) .build() ) + .licenseType( + Price.UnitPrice.LicenseType.builder() + .id("id") + .groupingKey("grouping_key") + .name("name") + .build() + ) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addUsageCustomerId("string") + .metricParameterOverrides( + PriceInterval.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .redeemedCoupon( 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 0de61a15a..b5fa2b8fd 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 @@ -86,7 +86,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -130,6 +132,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -196,7 +199,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -240,6 +245,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -306,7 +312,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -350,6 +358,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -416,7 +425,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -460,6 +471,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -526,7 +538,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -570,6 +584,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -636,7 +651,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -680,6 +697,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -746,7 +764,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -790,6 +810,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -856,7 +877,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -900,6 +923,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -966,7 +990,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -1010,6 +1036,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1076,7 +1103,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -1120,6 +1149,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1186,7 +1216,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -1230,6 +1262,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1296,7 +1329,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -1340,6 +1375,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1406,7 +1442,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -1450,6 +1488,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1516,7 +1555,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -1560,6 +1601,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1626,7 +1668,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -1670,6 +1714,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1736,7 +1781,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -1780,6 +1827,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -1844,7 +1892,9 @@ internal class ErrorHandlingTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType( + AccountingProviderConfig.ProviderType.QUICKBOOKS + ) .build() ) .excluded(true) @@ -1888,6 +1938,7 @@ internal class ErrorHandlingTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .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 447c39875..23814587c 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 @@ -56,7 +56,7 @@ internal class ServiceParamsTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -98,6 +98,7 @@ internal class ServiceParamsTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .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 d1dc0d04a..10cd9480d 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 @@ -131,7 +131,24 @@ internal class AlertServiceAsyncTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .addPriceFilter( + AlertCreateForSubscriptionParams.PriceFilter.builder() + .field(AlertCreateForSubscriptionParams.PriceFilter.Field.PRICE_ID) + .operator( + AlertCreateForSubscriptionParams.PriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .pricingUnitId("pricing_unit_id") + .addThresholdOverride( + AlertCreateForSubscriptionParams.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt index 0093f1b67..18e0fc081 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/BetaServiceAsyncTest.kt @@ -88,9 +88,93 @@ internal class BetaServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -141,6 +225,7 @@ internal class BetaServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,9 +302,97 @@ internal class BetaServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -270,6 +443,7 @@ internal class BetaServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt index 61350631a..c58df3b7b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditBlockServiceAsyncTest.kt @@ -38,4 +38,19 @@ internal class CreditBlockServiceAsyncTest { val response = future.get() } + + @Test + fun listInvoices() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val creditBlockServiceAsync = client.creditBlocks() + + val responseFuture = creditBlockServiceAsync.listInvoices("block_id") + + val response = responseFuture.get() + response.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 39f99789e..3663f0e16 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 @@ -40,7 +40,7 @@ internal class CustomerServiceAsyncTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -82,6 +82,7 @@ internal class CustomerServiceAsyncTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -143,7 +144,7 @@ internal class CustomerServiceAsyncTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -187,6 +188,7 @@ internal class CustomerServiceAsyncTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -337,7 +339,7 @@ internal class CustomerServiceAsyncTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -384,6 +386,7 @@ internal class CustomerServiceAsyncTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) 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 636faaff3..54516a532 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 @@ -9,7 +9,9 @@ import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceDeleteLineItemParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams import com.withorb.api.models.InvoiceMarkPaidParams +import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount import com.withorb.api.models.UnitConfig @@ -51,6 +53,7 @@ internal class InvoiceServiceAsyncTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -98,6 +101,7 @@ internal class InvoiceServiceAsyncTest { invoiceServiceAsync.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -199,6 +203,27 @@ internal class InvoiceServiceAsyncTest { invoice.validate() } + @Test + fun issueSummary() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val invoiceServiceAsync = client.invoices() + + val responseFuture = + invoiceServiceAsync.issueSummary( + InvoiceIssueSummaryParams.builder() + .invoiceId("invoice_id") + .synchronous(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Test fun listSummary() { val client = @@ -246,7 +271,13 @@ internal class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = invoiceServiceAsync.pay("invoice_id") + val invoiceFuture = + invoiceServiceAsync.pay( + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() + ) val invoice = invoiceFuture.get() invoice.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt new file mode 100644 index 000000000..b620e553e --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseServiceAsyncTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseServiceAsyncTest { + + @Test + fun create() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val licenseFuture = + licenseServiceAsync.create( + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + ) + + val license = licenseFuture.get() + license.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val licenseFuture = licenseServiceAsync.retrieve("license_id") + + val license = licenseFuture.get() + license.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val pageFuture = + licenseServiceAsync.list( + LicenseListParams.builder().subscriptionId("subscription_id").build() + ) + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun deactivate() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val responseFuture = + licenseServiceAsync.deactivate( + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Test + fun retrieveByExternalId() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseServiceAsync = client.licenses() + + val responseFuture = + licenseServiceAsync.retrieveByExternalId( + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt new file mode 100644 index 000000000..32cf49052 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/LicenseTypeServiceAsyncTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseTypeCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseTypeServiceAsyncTest { + + @Test + fun create() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeServiceAsync = client.licenseTypes() + + val licenseTypeFuture = + licenseTypeServiceAsync.create( + LicenseTypeCreateParams.builder().groupingKey("x").name("x").build() + ) + + val licenseType = licenseTypeFuture.get() + licenseType.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeServiceAsync = client.licenseTypes() + + val licenseTypeFuture = licenseTypeServiceAsync.retrieve("license_type_id") + + val licenseType = licenseTypeFuture.get() + licenseType.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeServiceAsync = client.licenseTypes() + + val pageFuture = licenseTypeServiceAsync.list() + + val page = pageFuture.get() + page.response().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 709bba422..0951b3266 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 @@ -57,9 +57,87 @@ internal class PlanServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Cadence.ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + PlanCreateParams.Price.LicenseAllocationPrice.ModelType.UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -110,6 +188,7 @@ internal class PlanServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -151,6 +230,7 @@ internal class PlanServiceAsyncTest { .build() ) .defaultInvoiceMemo("default_invoice_memo") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanCreateParams.Metadata.builder() @@ -187,6 +267,7 @@ internal class PlanServiceAsyncTest { planServiceAsync.update( PlanUpdateParams.builder() .planId("plan_id") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanUpdateParams.Metadata.builder() 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 2738e47c1..30385ba2a 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 @@ -9,7 +9,6 @@ import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewFloatingUnitPrice -import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluatePreviewEventsParams @@ -33,55 +32,47 @@ internal class PriceServiceAsyncTest { val priceFuture = priceServiceAsync.create( - PriceCreateParams.builder() - .body( - NewFloatingUnitPrice.builder() - .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingUnitPrice.ModelType.UNIT) - .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .prorated(true) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId( - "external_dimensional_price_group_id" - ) - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingUnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) + NewFloatingUnitPrice.builder() + .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) + .currency("currency") + .itemId("item_id") + .modelType(NewFloatingUnitPrice.ModelType.UNIT) + .name("Annual fee") + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + NewFloatingUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .build() @@ -150,6 +141,11 @@ internal class PriceServiceAsyncTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) @@ -180,6 +176,12 @@ internal class PriceServiceAsyncTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -229,6 +231,7 @@ internal class PriceServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -282,6 +285,13 @@ internal class PriceServiceAsyncTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -331,6 +341,7 @@ internal class PriceServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) 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 513e0f995..9c0be7f55 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 @@ -6,6 +6,7 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.BillingCycleAnchorConfiguration +import com.withorb.api.models.BillingCycleRelativeDate import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.CustomExpiration import com.withorb.api.models.DiscountOverride @@ -103,6 +104,12 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -117,6 +124,11 @@ internal class SubscriptionServiceAsyncTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -168,6 +180,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -274,6 +287,12 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -288,6 +307,12 @@ internal class SubscriptionServiceAsyncTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -338,6 +363,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -527,7 +553,7 @@ internal class SubscriptionServiceAsyncTest { .subscriptionId("subscription_id") .addAdd( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -548,12 +574,18 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -564,6 +596,12 @@ internal class SubscriptionServiceAsyncTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -614,6 +652,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -627,7 +666,7 @@ internal class SubscriptionServiceAsyncTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -654,7 +693,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .allowInvoiceCreditOrVoid(true) @@ -664,7 +703,7 @@ internal class SubscriptionServiceAsyncTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition @@ -673,15 +712,21 @@ internal class SubscriptionServiceAsyncTest { .quantity(5L) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) .addEditAdjustment( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .build() @@ -784,6 +829,12 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -798,6 +849,13 @@ internal class SubscriptionServiceAsyncTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -849,6 +907,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -946,6 +1005,12 @@ internal class SubscriptionServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -960,6 +1025,13 @@ internal class SubscriptionServiceAsyncTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -1010,6 +1082,7 @@ internal class SubscriptionServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt index 304861b85..353e3cb13 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/beta/ExternalPlanIdServiceAsyncTest.kt @@ -88,9 +88,98 @@ internal class ExternalPlanIdServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -141,6 +230,7 @@ internal class ExternalPlanIdServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,9 +307,98 @@ internal class ExternalPlanIdServiceAsyncTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -270,6 +449,7 @@ internal class ExternalPlanIdServiceAsyncTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) 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 8fffa8b4e..b6c3884c8 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 @@ -73,6 +73,7 @@ internal class LedgerServiceAsyncTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -143,6 +144,7 @@ internal class LedgerServiceAsyncTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt new file mode 100644 index 000000000..445726bb1 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/ExternalLicenseServiceAsyncTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExternalLicenseServiceAsyncTest { + + @Test + fun getUsage() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val externalLicenseServiceAsync = client.licenses().externalLicenses() + + val responseFuture = + externalLicenseServiceAsync.getUsage( + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt new file mode 100644 index 000000000..72f120b68 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/licenses/UsageServiceAsyncTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.async.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageServiceAsyncTest { + + @Test + fun getAllUsage() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageServiceAsync = client.licenses().usage() + + val responseFuture = + usageServiceAsync.getAllUsage( + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Test + fun getUsage() { + val client = + OrbOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageServiceAsync = client.licenses().usage() + + val responseFuture = + usageServiceAsync.getUsage( + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + 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 c600a995b..da0c616df 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 @@ -25,6 +25,7 @@ internal class ExternalPlanIdServiceAsyncTest { externalPlanIdServiceAsync.update( PlanExternalPlanIdUpdateParams.builder() .otherExternalPlanId("external_plan_id") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanExternalPlanIdUpdateParams.Metadata.builder() 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 9ab70abdb..99d0aed3b 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 @@ -126,7 +126,24 @@ internal class AlertServiceTest { .subscriptionId("subscription_id") .addThreshold(Threshold.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) + .addGroupingKey("string") .metricId("metric_id") + .addPriceFilter( + AlertCreateForSubscriptionParams.PriceFilter.builder() + .field(AlertCreateForSubscriptionParams.PriceFilter.Field.PRICE_ID) + .operator( + AlertCreateForSubscriptionParams.PriceFilter.Operator.INCLUDES + ) + .addValue("string") + .build() + ) + .pricingUnitId("pricing_unit_id") + .addThresholdOverride( + AlertCreateForSubscriptionParams.ThresholdOverride.builder() + .addGroupValue("string") + .addThreshold(Threshold.builder().value(0.0).build()) + .build() + ) .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt index 7f538b370..c82f5f106 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/BetaServiceTest.kt @@ -88,9 +88,93 @@ internal class BetaServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .builder() + .cadence( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.AddPrice.LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -141,6 +225,7 @@ internal class BetaServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,9 +302,97 @@ internal class BetaServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaCreatePlanVersionParams.ReplacePrice.LicenseAllocationPrice + .builder() + .cadence( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -270,6 +443,7 @@ internal class BetaServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt index b52247712..9e7a7b279 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditBlockServiceTest.kt @@ -35,4 +35,18 @@ internal class CreditBlockServiceTest { creditBlockService.delete("block_id") } + + @Test + fun listInvoices() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val creditBlockService = client.creditBlocks() + + val response = creditBlockService.listInvoices("block_id") + + response.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 30037704e..c5ddd90b9 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 @@ -40,7 +40,7 @@ internal class CustomerServiceTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -82,6 +82,7 @@ internal class CustomerServiceTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -142,7 +143,7 @@ internal class CustomerServiceTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -186,6 +187,7 @@ internal class CustomerServiceTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) @@ -323,7 +325,7 @@ internal class CustomerServiceTest { .addAccountingProvider( AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() ) .excluded(true) @@ -370,6 +372,7 @@ internal class CustomerServiceTest { .ProviderType .STRIPE ) + .defaultSharedPaymentToken("default_shared_payment_token") .addExcludedPaymentMethodType("string") .build() ) 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 5a0c09455..1b075f526 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 @@ -9,7 +9,9 @@ import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceDeleteLineItemParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams +import com.withorb.api.models.InvoiceIssueSummaryParams import com.withorb.api.models.InvoiceMarkPaidParams +import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.PercentageDiscount import com.withorb.api.models.UnitConfig @@ -51,6 +53,7 @@ internal class InvoiceServiceTest { ) .build() ) + .autoCollection(true) .customerId("4khy3nwzktxv7") .discount( PercentageDiscount.builder() @@ -97,6 +100,7 @@ internal class InvoiceServiceTest { invoiceService.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") + .autoCollection(true) .dueDate(LocalDate.parse("2023-09-22")) .invoiceDate(LocalDate.parse("2023-09-22")) .metadata( @@ -190,6 +194,26 @@ internal class InvoiceServiceTest { invoice.validate() } + @Test + fun issueSummary() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val invoiceService = client.invoices() + + val response = + invoiceService.issueSummary( + InvoiceIssueSummaryParams.builder() + .invoiceId("invoice_id") + .synchronous(true) + .build() + ) + + response.validate() + } + @Test fun listSummary() { val client = @@ -235,7 +259,13 @@ internal class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = invoiceService.pay("invoice_id") + val invoice = + invoiceService.pay( + InvoicePayParams.builder() + .invoiceId("invoice_id") + .sharedPaymentTokenId("shared_payment_token_id") + .build() + ) invoice.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt new file mode 100644 index 000000000..739be45b4 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseServiceTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseCreateParams +import com.withorb.api.models.LicenseDeactivateParams +import com.withorb.api.models.LicenseListParams +import com.withorb.api.models.LicenseRetrieveByExternalIdParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseServiceTest { + + @Test + fun create() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val license = + licenseService.create( + LicenseCreateParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .endDate(LocalDate.parse("2026-01-27")) + .startDate(LocalDate.parse("2026-01-27")) + .build() + ) + + license.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val license = licenseService.retrieve("license_id") + + license.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val page = + licenseService.list( + LicenseListParams.builder().subscriptionId("subscription_id").build() + ) + + page.response().validate() + } + + @Test + fun deactivate() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val response = + licenseService.deactivate( + LicenseDeactivateParams.builder() + .licenseId("license_id") + .endDate(LocalDate.parse("2026-01-27")) + .build() + ) + + response.validate() + } + + @Test + fun retrieveByExternalId() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseService = client.licenses() + + val response = + licenseService.retrieveByExternalId( + LicenseRetrieveByExternalIdParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .build() + ) + + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt new file mode 100644 index 000000000..11454dfc8 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/LicenseTypeServiceTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseTypeCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LicenseTypeServiceTest { + + @Test + fun create() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeService = client.licenseTypes() + + val licenseType = + licenseTypeService.create( + LicenseTypeCreateParams.builder().groupingKey("x").name("x").build() + ) + + licenseType.validate() + } + + @Test + fun retrieve() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeService = client.licenseTypes() + + val licenseType = licenseTypeService.retrieve("license_type_id") + + licenseType.validate() + } + + @Test + fun list() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val licenseTypeService = client.licenseTypes() + + val page = licenseTypeService.list() + + page.response().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 62e6a8a4e..33ea228b4 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 @@ -57,9 +57,87 @@ internal class PlanServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + PlanCreateParams.Price.LicenseAllocationPrice.builder() + .cadence( + PlanCreateParams.Price.LicenseAllocationPrice.Cadence.ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + PlanCreateParams.Price.LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + PlanCreateParams.Price.LicenseAllocationPrice.ModelType.UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + PlanCreateParams.Price.LicenseAllocationPrice.Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -110,6 +188,7 @@ internal class PlanServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -151,6 +230,7 @@ internal class PlanServiceTest { .build() ) .defaultInvoiceMemo("default_invoice_memo") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanCreateParams.Metadata.builder() @@ -186,6 +266,7 @@ internal class PlanServiceTest { planService.update( PlanUpdateParams.builder() .planId("plan_id") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanUpdateParams.Metadata.builder() 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 de3c5a9ae..38342a961 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 @@ -9,7 +9,6 @@ import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.NewBillingCycleConfiguration import com.withorb.api.models.NewDimensionalPriceConfiguration import com.withorb.api.models.NewFloatingUnitPrice -import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateMultipleParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluatePreviewEventsParams @@ -33,55 +32,47 @@ internal class PriceServiceTest { val price = priceService.create( - PriceCreateParams.builder() - .body( - NewFloatingUnitPrice.builder() - .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) - .currency("currency") - .itemId("item_id") - .modelType(NewFloatingUnitPrice.ModelType.UNIT) - .name("Annual fee") - .unitConfig( - UnitConfig.builder() - .unitAmount("unit_amount") - .prorated(true) - .build() - ) - .billableMetricId("billable_metric_id") - .billedInAdvance(true) - .billingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .conversionRate(0.0) - .unitConversionRateConfig( - ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() - ) - .dimensionalPriceConfiguration( - NewDimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .externalDimensionalPriceGroupId( - "external_dimensional_price_group_id" - ) - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoiceGroupingKey("x") - .invoicingCycleConfiguration( - NewBillingCycleConfiguration.builder() - .duration(0L) - .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) - .build() - ) - .metadata( - NewFloatingUnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) + NewFloatingUnitPrice.builder() + .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) + .currency("currency") + .itemId("item_id") + .modelType(NewFloatingUnitPrice.ModelType.UNIT) + .name("Annual fee") + .unitConfig( + UnitConfig.builder().unitAmount("unit_amount").prorated(true).build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId("external_dimensional_price_group_id") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfiguration.DurationUnit.DAY) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + NewFloatingUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .build() @@ -147,6 +138,11 @@ internal class PriceServiceTest { .externalCustomerId("external_customer_id") .filter("my_numeric_property > 100 AND my_other_property = 'bar'") .addGroupingKey("case when my_event_type = 'foo' then true else false end") + .metricParameterOverrides( + PriceEvaluateParams.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) @@ -176,6 +172,12 @@ internal class PriceServiceTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluateMultipleParams.PriceEvaluation.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -225,6 +227,7 @@ internal class PriceServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -277,6 +280,13 @@ internal class PriceServiceTest { .addGroupingKey( "case when my_event_type = 'foo' then true else false end" ) + .metricParameterOverrides( + PriceEvaluatePreviewEventsParams.PriceEvaluation + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .price( NewFloatingUnitPrice.builder() .cadence(NewFloatingUnitPrice.Cadence.ANNUAL) @@ -326,6 +336,7 @@ internal class PriceServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) 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 457bb6fcd..bf9c72f92 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 @@ -6,6 +6,7 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.BillingCycleAnchorConfiguration +import com.withorb.api.models.BillingCycleRelativeDate import com.withorb.api.models.ConversionRateUnitConfig import com.withorb.api.models.CustomExpiration import com.withorb.api.models.DiscountOverride @@ -103,6 +104,12 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -117,6 +124,11 @@ internal class SubscriptionServiceTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.AddPrice.MetricParameterOverrides.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -168,6 +180,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -274,6 +287,12 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -288,6 +307,12 @@ internal class SubscriptionServiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionCreateParams.ReplacePrice.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -338,6 +363,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -519,7 +545,7 @@ internal class SubscriptionServiceTest { .subscriptionId("subscription_id") .addAdd( SubscriptionPriceIntervalsParams.Add.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .allocationPrice( NewAllocationPrice.builder() .amount("10.00") @@ -540,12 +566,18 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) .canDeferBilling(true) .addAmountDiscount(0.0) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( @@ -556,6 +588,12 @@ internal class SubscriptionServiceTest { .build() ) .maximumAmount(0.0) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Add.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount(0.0) .price( NewFloatingUnitPrice.builder() @@ -606,6 +644,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -619,7 +658,7 @@ internal class SubscriptionServiceTest { ) .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .adjustment( NewPercentageDiscount.builder() .adjustmentType( @@ -646,7 +685,7 @@ internal class SubscriptionServiceTest { .build() ) .adjustmentId("h74gfhdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .allowInvoiceCreditOrVoid(true) @@ -656,7 +695,7 @@ internal class SubscriptionServiceTest { .priceIntervalId("sdfs6wdjvn7ujokd") .billingCycleDay(0L) .canDeferBilling(true) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition @@ -665,15 +704,21 @@ internal class SubscriptionServiceTest { .quantity(5L) .build() ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metricParameterOverrides( + SubscriptionPriceIntervalsParams.Edit.MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .addUsageCustomerId("string") .build() ) .addEditAdjustment( SubscriptionPriceIntervalsParams.EditAdjustment.builder() .adjustmentIntervalId("sdfs6wdjvn7ujokd") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(BillingCycleRelativeDate.START_OF_TERM) + .startDate(BillingCycleRelativeDate.START_OF_TERM) .build() ) .build() @@ -774,6 +819,12 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -788,6 +839,13 @@ internal class SubscriptionServiceTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.AddPrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .planPhaseOrder(0L) .price( @@ -839,6 +897,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -936,6 +995,12 @@ internal class SubscriptionServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) @@ -950,6 +1015,13 @@ internal class SubscriptionServiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(2.0) .maximumAmount("1.23") + .metricParameterOverrides( + SubscriptionSchedulePlanChangeParams.ReplacePrice + .MetricParameterOverrides + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .minimumAmount("1.23") .price( NewSubscriptionUnitPrice.builder() @@ -1000,6 +1072,7 @@ internal class SubscriptionServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewSubscriptionUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt index 961704179..c4a7cd65b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/beta/ExternalPlanIdServiceTest.kt @@ -88,9 +88,98 @@ internal class ExternalPlanIdServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.AddPrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -141,6 +230,7 @@ internal class ExternalPlanIdServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -217,9 +307,98 @@ internal class ExternalPlanIdServiceTest { .build() ) .itemId("item_id") + .licenseTypeId("license_type_id") + .metadata( + NewAllocationPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .perUnitCostBasis("per_unit_cost_basis") .build() ) + .licenseAllocationPrice( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .builder() + .cadence( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Cadence + .ANNUAL + ) + .itemId("item_id") + .addLicenseAllocation( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .LicenseAllocation + .builder() + .amount("amount") + .currency("currency") + .writeOffOverage(true) + .build() + ) + .modelType( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .ModelType + .UNIT + ) + .name("Annual fee") + .unitConfig( + UnitConfig.builder() + .unitAmount("unit_amount") + .prorated(true) + .build() + ) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .conversionRate(0.0) + .unitConversionRateConfig( + ConversionRateUnitConfig.builder() + .unitAmount("unit_amount") + .build() + ) + .currency("currency") + .dimensionalPriceConfiguration( + NewDimensionalPriceConfiguration.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .externalDimensionalPriceGroupId( + "external_dimensional_price_group_id" + ) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("x") + .invoicingCycleConfiguration( + NewBillingCycleConfiguration.builder() + .duration(0L) + .durationUnit( + NewBillingCycleConfiguration.DurationUnit.DAY + ) + .build() + ) + .licenseTypeId("license_type_id") + .metadata( + BetaExternalPlanIdCreatePlanVersionParams.ReplacePrice + .LicenseAllocationPrice + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) .planPhaseOrder(0L) .price( NewPlanUnitPrice.builder() @@ -270,6 +449,7 @@ internal class ExternalPlanIdServiceTest { ) .build() ) + .licenseTypeId("license_type_id") .metadata( NewPlanUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) 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 3db03f154..ded8e622d 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 @@ -72,6 +72,7 @@ internal class LedgerServiceTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) @@ -141,6 +142,7 @@ internal class LedgerServiceTest { .customDueDate(LocalDate.parse("2019-12-27")) .invoiceDate(LocalDate.parse("2019-12-27")) .itemId("item_id") + .markAsPaid(true) .memo("memo") .netTerms(0L) .requireSuccessfulPayment(true) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt new file mode 100644 index 000000000..3bb995d17 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/ExternalLicenseServiceTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseExternalLicenseGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ExternalLicenseServiceTest { + + @Test + fun getUsage() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val externalLicenseService = client.licenses().externalLicenses() + + val response = + externalLicenseService.getUsage( + LicenseExternalLicenseGetUsageParams.builder() + .externalLicenseId("external_license_id") + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt new file mode 100644 index 000000000..34ec9d205 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/licenses/UsageServiceTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.services.blocking.licenses + +import com.withorb.api.TestServerExtension +import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.LicenseUsageGetAllUsageParams +import com.withorb.api.models.LicenseUsageGetUsageParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageServiceTest { + + @Test + fun getAllUsage() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageService = client.licenses().usage() + + val response = + usageService.getAllUsage( + LicenseUsageGetAllUsageParams.builder() + .licenseTypeId("license_type_id") + .subscriptionId("subscription_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } + + @Test + fun getUsage() { + val client = + OrbOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val usageService = client.licenses().usage() + + val response = + usageService.getUsage( + LicenseUsageGetUsageParams.builder() + .licenseId("license_id") + .cursor("cursor") + .endDate(LocalDate.parse("2019-12-27")) + .addGroupBy("string") + .limit(1L) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + 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 1dc620ee8..701c30d07 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 @@ -25,6 +25,7 @@ internal class ExternalPlanIdServiceTest { externalPlanIdService.update( PlanExternalPlanIdUpdateParams.builder() .otherExternalPlanId("external_plan_id") + .description("description") .externalPlanId("external_plan_id") .metadata( PlanExternalPlanIdUpdateParams.Metadata.builder() diff --git a/orb-java-example/build.gradle.kts b/orb-java-example/build.gradle.kts index 3e7cb2236..818cd7587 100644 --- a/orb-java-example/build.gradle.kts +++ b/orb-java-example/build.gradle.kts @@ -8,7 +8,8 @@ repositories { } dependencies { - implementation(project(":orb-java")) + implementation(project(":orb-java-core")) + implementation(project(":orb-java-client-okhttp")) } tasks.withType().configureEach { diff --git a/orb-java-proguard-test/build.gradle.kts b/orb-java-proguard-test/build.gradle.kts index a738f0f3e..e68c59a0b 100644 --- a/orb-java-proguard-test/build.gradle.kts +++ b/orb-java-proguard-test/build.gradle.kts @@ -18,7 +18,7 @@ dependencies { testImplementation(project(":orb-java")) testImplementation(kotlin("test")) testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } diff --git a/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt b/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt index ce15e3f90..12f28afb9 100644 --- a/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt +++ b/orb-java-proguard-test/src/test/kotlin/com/withorb/api/proguard/ProGuardCompatibilityTest.kt @@ -68,6 +68,8 @@ internal class ProGuardCompatibilityTest { assertThat(client.dimensionalPriceGroups()).isNotNull() assertThat(client.subscriptionChanges()).isNotNull() assertThat(client.creditBlocks()).isNotNull() + assertThat(client.licenseTypes()).isNotNull() + assertThat(client.licenses()).isNotNull() } @Test @@ -76,7 +78,7 @@ internal class ProGuardCompatibilityTest { val accountingProviderConfig = AccountingProviderConfig.builder() .externalProviderId("external_provider_id") - .providerType("provider_type") + .providerType(AccountingProviderConfig.ProviderType.QUICKBOOKS) .build() val roundtrippedAccountingProviderConfig = diff --git a/scripts/build b/scripts/build index f40634826..16a2b00db 100755 --- a/scripts/build +++ b/scripts/build @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Building classes" -./gradlew build testClasses -x test +./gradlew build testClasses "$@" -x test diff --git a/scripts/fast-format b/scripts/fast-format index 1b3bc473a..35a1dee25 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -24,8 +24,8 @@ if [ ! -f "$FILE_LIST" ]; then exit 1 fi -if ! command -v ktfmt-fast-format &> /dev/null; then - echo "Error: ktfmt-fast-format not found" +if ! command -v ktfmt &> /dev/null; then + echo "Error: ktfmt not found" exit 1 fi @@ -36,7 +36,7 @@ echo "==> Done looking for Kotlin files" if [[ -n "$kt_files" ]]; then echo "==> will format Kotlin files" - echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt --kotlinlang-style "$@" else echo "No Kotlin files to format -- expected outcome during incremental formatting" fi diff --git a/scripts/mock b/scripts/mock index 0b28f6ea2..04d29019f 100755 --- a/scripts/mock +++ b/scripts/mock @@ -19,23 +19,34 @@ fi echo "==> Starting mock server with URL ${URL}" -# Run prism mock on the given spec +# Run steady mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + # Pre-install the package so the download doesn't eat into the startup timeout + npm exec --package=@stdy/cli@0.22.1 -- steady --version - # Wait for server to come online + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + + # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + attempts=0 + while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do + if ! kill -0 $! 2>/dev/null; then + echo + cat .stdy.log + exit 1 + fi + attempts=$((attempts + 1)) + if [ "$attempts" -ge 300 ]; then + echo + echo "Timed out waiting for Steady server to start" + cat .stdy.log + exit 1 + fi echo -n "." sleep 0.1 done - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - echo else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 047bc1dbb..e81baf829 100755 --- a/scripts/test +++ b/scripts/test @@ -9,8 +9,8 @@ GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 +function steady_is_running() { + curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1 } kill_server_on_port() { @@ -25,7 +25,7 @@ function is_overriding_api_base_url() { [ -n "$TEST_API_BASE_URL" ] } -if ! is_overriding_api_base_url && ! prism_is_running ; then +if ! is_overriding_api_base_url && ! steady_is_running ; then # When we exit this script, make sure to kill the background mock server process trap 'kill_server_on_port 4010' EXIT @@ -36,19 +36,19 @@ fi if is_overriding_api_base_url ; then echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" +elif ! steady_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server" echo -e "running against your OpenAPI spec." echo echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" + echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}" echo fi diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts index 548d15272..10f3c7055 100755 --- a/scripts/upload-artifacts +++ b/scripts/upload-artifacts @@ -96,8 +96,52 @@ generate_instructions() {

Stainless SDK Maven Repository

This is the Maven repository for your Stainless Java SDK build.

-

Directions

-

To use the uploaded Maven repository, add the following to your project's pom.xml:

+

Project configuration

+ +

The details depend on whether you're using Maven or Gradle as your build tool.

+ +

Maven

+ +

Add the following to your project's pom.xml:

+
<repositories>
+    <repository>
+        <id>stainless-sdk-repo</id>
+        <url>https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn</url>
+    </repository>
+</repositories>
+ +

Gradle

+

Add the following to your build.gradle file:

+
repositories {
+    maven {
+        url "https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn"
+    }
+}
+ +
+

Configuring authentication (if required)

+ +

Some accounts may require authentication to access the repository. If so, use the + following instructions, replacing YOUR_STAINLESS_API_TOKEN with your actual token.

+ +

Maven with authentication

+ +

First, ensure you have the following in your Maven settings.xml for repo authentication:

+
<servers>
+    <server>
+        <id>stainless-sdk-repo</id>
+        <configuration>
+            <httpHeaders>
+                <property>
+                    <name>Authorization</name>
+                    <value>Bearer YOUR_STAINLESS_API_TOKEN</value>
+                </property>
+            </httpHeaders>
+        </configuration>
+    </server>
+</servers>
+ +

Then, add the following to your project's pom.xml:

<repositories>
     <repository>
         <id>stainless-sdk-repo</id>
@@ -105,14 +149,24 @@ generate_instructions() {
     </repository>
 </repositories>
-

If you're using Gradle, add the following to your build.gradle file:

+

Gradle with authentication

+

Add the following to your build.gradle file:

repositories {
     maven {
-        url 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'
+        url "https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn"
+        credentials(HttpHeaderCredentials) {
+            name = "Authorization"
+            value = "Bearer YOUR_STAINLESS_API_TOKEN"
+        }
+        authentication {
+            header(HttpHeaderAuthentication)
+        }
     }
 }
+
-

Once you've added the repository, you can include dependencies from it as usual. See your +

Using the repository

+

Once you've configured the repository, you can include dependencies from it as usual. See your project README for more details.